bool anIsSectionClosed = aPolylineXY->IsClosedSection( 0 );
HYDROData_IPolyline::SectionType aSectionType = aPolylineXY->GetSectionType( 0 );
- NCollection_Sequence<Polyline3DPoint> aResPoints = GetProfilePoints3D();
+ NCollection_Sequence<Polyline3DPoint> aResPoints = GetProfilePoints3D(false);
TopoDS_Wire aResWire = HYDROData_PolylineXY::BuildWire( aSectionType, anIsSectionClosed, aResPoints );
SetTopShape( aResWire );
SetShape3D( aResWire );
}
-HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetProfilePoints3D()
+HYDROData_Polyline3D::Polyline3DPoints HYDROData_Polyline3D::GetProfilePoints3D(bool IsConvertToGlobal)
{
Handle(HYDROData_PolylineXY) aPolylineXY = GetPolylineXY();
if ( aPolylineXY.IsNull() )
// Add last point as is
aResPoints.Append( Polyline3DPoint( aLastPoint.X(), aLastPoint.Y(), aLastParPoint.Y() ) );
+ if (IsConvertToGlobal)
+ {
+ Handle(HYDROData_Document) aDoc = HYDROData_Document::Document( myLab );
+ for (int i=1;i<=aResPoints.Size();i++)
+ {
+ gp_XYZ& point = aResPoints.ChangeValue(i);
+ aDoc->Transform( point, false );
+ }
+ }
return aResPoints;
}
*/
HYDRODATA_EXPORT virtual void RemoveAltitudeObject();
- HYDRODATA_EXPORT Polyline3DPoints GetProfilePoints3D();
+ HYDRODATA_EXPORT Polyline3DPoints GetProfilePoints3D(bool IsConvertToGlobal);
/**
* Returns the child u,z profile which has been generated from bathymetry.
return aResList;
}
-void HYDROData_ProfileUZ::CalculateAndAddPoints(const NCollection_Sequence<gp_XYZ>& theXYZPoints, Handle(HYDROData_PolylineXY)& thePolylineXY)
+void HYDROData_ProfileUZ::CalculateAndAddPoints(const NCollection_Sequence<gp_XYZ>& theXYZPoints,
+ Handle(HYDROData_PolylineXY)& thePolylineXY,
+ bool fillPolyXY)
{
// Fill 2D polyline
- for ( int i = 1; i <= theXYZPoints.Size(); i++ ) {
- const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i );
- thePolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
+ if (fillPolyXY)
+ {
+ for ( int i = 1; i <= theXYZPoints.Size(); i++ ) {
+ const HYDROData_Profile::ProfilePoint& aBottomPoint = theXYZPoints.Value( i );
+ thePolylineXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
+ }
}
-
+
// Calculate profile UZ points
// First point
HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1, bool IsConvertToGlobal = false ) const;
HYDRODATA_EXPORT virtual void CalculateAndAddPoints(const NCollection_Sequence<gp_XYZ>& theXYZPoints,
- Handle(HYDROData_PolylineXY)& thePolylineXY);
+ Handle(HYDROData_PolylineXY)& thePolylineXY, bool fillPolyXY);
protected:
if (thePoly->GetPolylineXY()->GetSectionType(0) == HYDROData_IPolyline::SECTION_SPLINE)
return -1;
- HYDROData_Polyline3D::Polyline3DPoints aPointList3D = thePoly->GetProfilePoints3D();
+ HYDROData_Polyline3D::Polyline3DPoints aPointList3D = thePoly->GetProfilePoints3D(true);
for (int j = 1; j <= aPointList3D.Size(); j++)
{
const gp_XYZ& P = aPointList3D(j);
}
-bool HYDROData_ShapeFile::Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile)
+bool HYDROData_ShapeFile::Parse(SHPHandle theHandle, ShapeType theType)
{
int aShapeType;
mySHPObjects.clear();
SHPGetInfo( theHandle, NULL, &aShapeType, NULL, NULL );
- theShapeTypeOfFile = aShapeType;
+ //theShapeTypeOfFile = aShapeType;
bool ToRead = (theType == ShapeType_Polyline &&
(aShapeType == 3 || aShapeType == 13 || aShapeType == 23 || aShapeType == 5)) ||
(theType == ShapeType_Polygon && aShapeType == 5);
if (Stat != 0)
return Stat;
myHSHP = SHPOpen( theFileName.toLatin1().data(), "rb" );
- if (!Parse(myHSHP, HYDROData_ShapeFile::ShapeType_Polygon, theShapeTypeOfFile))
+ if (!Parse(myHSHP, HYDROData_ShapeFile::ShapeType_Polygon))
return 0;
for (size_t i = 0; i < mySHPObjects.size(); i++)
thePolygonsList.append("polygon_" + QString::number(i + 1));
void HYDROData_ShapeFile::ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, bool bReadAsPolyline)
{
-
Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) );
int nParts = anObj->nParts;
aPolylineXY->Update();
theEntities.Append(aPolylineXY);
+}
+
+
+void HYDROData_ShapeFile::ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj,
+ const Handle(HYDROData_PolylineXY)& aPolylineXY,
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities)
+{
+ Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( theDocument->CreateObject( KIND_POLYLINE ) );
+ Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( theDocument->CreateObject( KIND_BATHYMETRY ) );
+
+ HYDROData_Bathymetry::AltitudePoints aAPoints;
+
+ int nParts = anObj->nParts;
+ for ( int i = 0 ; i < nParts ; i++ )
+ {
+ //bool aSectClosure = true;
+ int StartIndex = anObj->panPartStart[i];
+ int EndIndex;
+ if (i != nParts - 1)
+ EndIndex = anObj->panPartStart[i + 1];
+ else
+ EndIndex = anObj->nVertices;
+
+ HYDROData_PolylineXY::SectionType aSectType = HYDROData_PolylineXY::SECTION_POLYLINE;
+ if (anObj->padfX[StartIndex] == anObj->padfX[EndIndex - 1] &&
+ anObj->padfY[StartIndex] == anObj->padfY[EndIndex - 1] &&
+ anObj->padfZ[StartIndex] == anObj->padfZ[EndIndex - 1])
+ EndIndex--;
+ for ( int k = StartIndex ; k < EndIndex ; k++ )
+ {
+ gp_XYZ xyz(anObj->padfX[k], anObj->padfY[k], anObj->padfZ[k]);
+ theDocument->Transform(xyz, true);
+ HYDROData_Bathymetry::AltitudePoint p;
+ p.X = xyz.X();
+ p.Y = xyz.Y();
+ p.Z = xyz.Z();
+ aAPoints.push_back(p);
+ }
+ }
+
+ QString PolyXYName = aPolylineXY->GetName();
+ QString aPoly3DName = PolyXYName, aBathyName = PolyXYName;
+ aPoly3DName.replace(PolyXYName.lastIndexOf("_PolyXY_"), 8, "_Poly3D_");
+ aBathyName.replace(PolyXYName.lastIndexOf("_Bath_"), 6, "_Poly3D_");
+
+ aBath->SetAltitudePoints(aAPoints);
+ aBath->SetName( aBathyName );
+
+ aPolylineObj->SetPolylineXY (aPolylineXY, false);
+ aPolylineObj->SetAltitudeObject(aBath);
+
+ aPolylineObj->SetBorderColor( aPolylineObj->DefaultBorderColor() );
+ aPolylineObj->SetName( aPoly3DName );
+
+ aPolylineObj->Update();
+ theEntities.Append(aPolylineObj);
}
+/*
void HYDROData_ShapeFile::ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
- int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities)
+ int theInd, bool XYOnly, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities)
{
Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theDocument->CreateObject( KIND_POLYLINEXY ) );
- Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( theDocument->CreateObject( KIND_POLYLINE ) );
+ Handle(HYDROData_Polyline3D) aPolylineObj;
+ Handle(HYDROData_Bathymetry) aBath;
+ if (!XYOnly)
+ {
+ Handle(HYDROData_Polyline3D) aPolylineObj = Handle(HYDROData_Polyline3D)::DownCast( theDocument->CreateObject( KIND_POLYLINE ) );
+ Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( theDocument->CreateObject( KIND_BATHYMETRY ) );
+ }
- Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( theDocument->CreateObject( KIND_BATHYMETRY ) );
HYDROData_Bathymetry::AltitudePoints aAPoints;
int nParts = anObj->nParts;
HYDROData_PolylineXY::Point aSectPoint = gp_XY(anObj->padfX[k], anObj->padfY[k]);
theDocument->Transform(aSectPoint, true);
aPolylineXY->AddPoint( i, aSectPoint );
- HYDROData_Bathymetry::AltitudePoint p;
- p.X = aSectPoint.X();
- p.Y = aSectPoint.Y();
- p.Z = anObj->padfZ[k];
- aAPoints.push_back(p);
+ if (!XYOnly)
+ {
+ HYDROData_Bathymetry::AltitudePoint p;
+ p.X = aSectPoint.X();
+ p.Y = aSectPoint.Y();
+ p.Z = anObj->padfZ[k];
+ aAPoints.push_back(p);
+ }
}
}
aPolylineXY->SetName( aPolyXYName );
aPolylineXY->SetWireColor(HYDROData_PolylineXY::DefaultWireColor());
aPolylineXY->Update();
-
- aBath->SetAltitudePoints(aAPoints);
- aBath->SetName( aBathName );
- aPolylineObj->SetPolylineXY (aPolylineXY, false);
- aPolylineObj->SetAltitudeObject(aBath);
+ if (!XYOnly)
+ {
+ aBath->SetAltitudePoints(aAPoints);
+ aBath->SetName( aBathName );
+
+ aPolylineObj->SetPolylineXY (aPolylineXY, false);
+ aPolylineObj->SetAltitudeObject(aBath);
+
+ aPolylineObj->SetBorderColor( aPolylineObj->DefaultBorderColor() );
+ aPolylineObj->SetName( aPoly3DName );
+
+ aPolylineObj->Update();
+ }
- aPolylineObj->SetBorderColor( aPolylineObj->DefaultBorderColor() );
- aPolylineObj->SetName( aPoly3DName );
-
- aPolylineObj->Update();
theEntities.Append(aPolylineXY);
- theEntities.Append(aPolylineObj);
-}
+ if (!XYOnly)
+ theEntities.Append(aPolylineObj);
+
+}*/
void HYDROData_ShapeFile::GetFreeIndices(std::vector<int>& theAllowedIndexes, QString strName, size_t theObjsSize,
QStringList theExistingNames, QString theBaseFileName)
}
}
-int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName,
- NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile, ImportShapeType theShapeTypesToImport)
+int HYDROData_ShapeFile::OpenAndParse(const QString& theFileName)
{
//Free();
int aStat = TryOpenShapeFile(theFileName);
if (aStat != 0)
return aStat;
+ //SHPHandle aHSHP;
+ myHSHP = SHPOpen( theFileName.toLatin1().data(), "rb" );
+ if (myHSHP == NULL)
+ return -1;
+
+ if (!Parse(myHSHP, HYDROData_ShapeFile::ShapeType_Polyline))
+ return -1;
+
+ return 1;
+ //sh_type = aHSHP->nShapeType;
+}
+
+int HYDROData_ShapeFile::ImportPolylines(Handle(HYDROData_Document) theDocument,
+ const QString& theFileName,
+ NCollection_IndexedDataMap<Handle(HYDROData_Entity), SHPObject*>& theEntitiesToSHPObj,
+ ImportShapeType theShapeTypesToImport)
+{
+ int aStat = -1;
+ int sh_type = myHSHP->nShapeType;
+ QFileInfo aFileInfo(theFileName);
+ QString aBaseFileName = aFileInfo.baseName();
HYDROData_Iterator anIter( theDocument );
int anInd = 0;
QStringList anExistingNames;
for( ; anIter.More(); anIter.Next() )
anExistingNames.push_back(anIter.Current()->GetName());
- SHPHandle aHSHP;
- aHSHP = SHPOpen( theFileName.toLatin1().data(), "rb" );
-
- QFileInfo aFileInfo(theFileName);
- QString aBaseFileName = aFileInfo.baseName();
-
- if (!Parse(aHSHP, HYDROData_ShapeFile::ShapeType_Polyline, theShapeTypeOfFile))
- return 0;
-
- int sh_type = aHSHP->nShapeType;
-
+ NCollection_Sequence<Handle(HYDROData_Entity)> Ents;
if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All ||
theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline)
&& (sh_type == 3 || sh_type == 23))
for (size_t i = 0; i < mySHPObjects.size(); i++ )
{
- ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], theEntities, false);
+ ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], Ents, false);
+ for (int k=1;k<=Ents.Size();k++)
+ theEntitiesToSHPObj.Add(Ents(k), mySHPObjects[i]);
}
aStat = 1;
}
}
for (size_t i = 0; i < mySHPObjects.size(); i++ )
{
- ReadSHPPoly3D(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], theEntities);
+ //ReadSHPPoly3D(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], false, theEntities);
+ ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], Ents, false); //TODO check Z coord on closeness
+ for (int k=1;k<=Ents.Size();k++)
+ theEntitiesToSHPObj.Add(Ents(k), mySHPObjects[i]);
}
aStat = 1;
}
for (size_t i = 0; i < mySHPObjects.size(); i++ )
{
- ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], theEntities, true);
+ ReadSHPPolyXY(theDocument, mySHPObjects[i], aBaseFileName, anAllowedIndexes[i], Ents, true);
+ for (int k=1;k<=Ents.Size();k++)
+ theEntitiesToSHPObj.Add(Ents(k), mySHPObjects[i]);
}
aStat = 2;
}
aStat = 0;
}
- for (size_t i = 0; i < mySHPObjects.size(); i++ )
- free (mySHPObjects[i]);
+ return aStat;
+}
- mySHPObjects.clear();
- SHPClose(aHSHP);
+int HYDROData_ShapeFile::GetShapeType() const
+{
+ if (myHSHP != NULL)
+ return myHSHP->nShapeType;
+ else
+ return -1;
+}
+
+int HYDROData_ShapeFile::ImportPolylines3D(Handle(HYDROData_Document) theDocument,
+ NCollection_IndexedDataMap<Handle(HYDROData_Entity), SHPObject*> thePolyXYToObj,
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
+ ImportShapeType theShapeTypesToImport)
+{
+ int aStat = -1;
+ int sh_type = myHSHP->nShapeType;
+ if ((theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All ||
+ theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_Polyline3D) && sh_type == 13)
+ {
+ //for (size_t i = 0; i < mySHPObjects.size(); i++ )
+ for (int i = 1; i <= thePolyXYToObj.Extent(); i++ )
+ {
+ Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( thePolyXYToObj.FindKey(i) );
+ ReadSHPPoly3D(theDocument, thePolyXYToObj(i), aPolylineXY, theEntities);
+ }
+ aStat = 1;
+ }
+ else
+ aStat = 0;
+
return aStat;
}
+
QString HYDROData_ShapeFile::GetShapeTypeName(int theType)
{
switch (theType)
void HYDROData_ShapeFile::DBF_GetFieldTypeList(std::vector<DBF_FieldType>& FTVect)
{
- int nWidth, nDecimals;
+ int nWidth, nDecimals;
char chField[12];
DBF_FieldType FT;
for( int i = 0; i < DBFGetFieldCount(myHDBF); i++ )
#include <NCollection_Sequence.hxx>
#include <TopTools_SequenceOfShape.hxx>
-
+#include <NCollection_IndexedDataMap.hxx>
#include <QStringList>
#include <vector>
-
//extern "C" {
#include <shapefil.h>
//};
int WriteObjectPolygon(Handle(HYDROData_Document) theDocument, SHPHandle theShpHandle,
const TopoDS_Shape& theInputShape, bool bUseDiscr, double theDefl );
//Import
- bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile);
+ bool Parse(SHPHandle theHandle, ShapeType theType);
//Import Landcover
void ReadSHPPolygon(Handle(HYDROData_Document) theDocument, SHPObject* anObj, int i, TopoDS_Face& F);
int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
bool bReadAsPolylin = false);
- void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
- int theInd, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
+ void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj,
+ const Handle(HYDROData_PolylineXY)& aPolylineXY,
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
HYDRODATA_EXPORT int ImportPolylines(Handle(HYDROData_Document) theDocument, const QString& theFileName,
- NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, int& theShapeTypeOfFile,
+ NCollection_IndexedDataMap<Handle(HYDROData_Entity), SHPObject*>& theEntitiesToSHPObj,
ImportShapeType theShapeTypesToImport);
+ HYDRODATA_EXPORT int ImportPolylines3D(Handle(HYDROData_Document) theDocument,
+ NCollection_IndexedDataMap<Handle(HYDROData_Entity), SHPObject*> thePolyXYToObj,
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
+ ImportShapeType theShapeTypesToImport);
+
+ HYDRODATA_EXPORT int OpenAndParse(const QString& theFileName);
+
+
HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
+ HYDRODATA_EXPORT int GetShapeType() const;
+
+
//DBF I/O Methods
HYDRODATA_EXPORT bool CheckDBFFileExisting(const QString& theSHPFilePath, QString& thePathToDBFFile);
HYDRODATA_EXPORT bool DBF_OpenDBF(const QString& thePathToDBFFile);
private:
std::vector<SHPObject*> mySHPObjects;
- SHPHandle myHSHP;
+ SHPHandle myHSHP;
DBFHandle myHDBF;
friend class test_HYDROData_ShapeFile;
}
-bool HYDROData_SinusX::Import(const QString& theFilePath, Handle(HYDROData_Document) theDocument,
- NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities)
+bool HYDROData_SinusX::OpenAndParse(const QString& theFilePath)
{
if ( theFilePath.isEmpty() )
{
aFile.open(QIODevice::ReadOnly);
Parse(aFile);
-
- CollectExistingNames(theDocument);
- SXToHydro(theDocument, theEntities);
-
aFile.close();
return true;
}
-void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities)
+void HYDROData_SinusX::Import(Handle(HYDROData_Document) theDocument,
+ NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities, std::vector<ImportOptions>* importOptions)
+{
+ CollectExistingNames(theDocument);
+ SXToHydro(theDocument, theEntities, importOptions);
+}
+
+
+void HYDROData_SinusX::SXToHydro(Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
+ std::vector<ImportOptions>* importOptions )
{
+ if (importOptions && (myCurveBlocks.size() != importOptions->size()))
+ importOptions = NULL; //incorrect input
+
for ( size_t i = 0; i < myCurveBlocks.size(); i++ )
{
if (myCurveBlocks[i].myType == 4) /// scatter plot -> to bathy
{
- Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( theDocument->CreateObject( KIND_BATHYMETRY ) );
- HYDROData_Bathymetry::AltitudePoints aAPoints;
- size_t n = myCurveBlocks[i].myXYZPoints.size();
- aAPoints.reserve( n );
- for (size_t j = 0; j < n; j++)
+ if (!importOptions || (importOptions && (*importOptions)[i].ImportAsBathy == true))
{
- gp_XYZ aLocalPoint = gp_XYZ (myCurveBlocks[i].myXYZPoints[j]);
- theDocument->Transform(aLocalPoint, true);
- HYDROData_Bathymetry::AltitudePoint p;
- p.X = aLocalPoint.X();
- p.Y = aLocalPoint.Y();
- p.Z = aLocalPoint.Z();
- aAPoints.push_back(p);
- }
+ Handle(HYDROData_Bathymetry) aBath = Handle(HYDROData_Bathymetry)::DownCast( theDocument->CreateObject( KIND_BATHYMETRY ) );
+ HYDROData_Bathymetry::AltitudePoints aAPoints;
+ size_t n = myCurveBlocks[i].myXYZPoints.size();
+ aAPoints.reserve( n );
+ for (size_t j = 0; j < n; j++)
+ {
+ gp_XYZ aLocalPoint = gp_XYZ (myCurveBlocks[i].myXYZPoints[j]);
+ theDocument->Transform(aLocalPoint, true);
+ HYDROData_Bathymetry::AltitudePoint p;
+ p.X = aLocalPoint.X();
+ p.Y = aLocalPoint.Y();
+ p.Z = aLocalPoint.Z();
+ aAPoints.push_back(p);
+ }
- aBath->SetAltitudePoints(aAPoints);
- aBath->SetName(GetName(myCurveBlocks[i].myName));
- theEntities.Append(aBath);
+ aBath->SetAltitudePoints(aAPoints);
+ aBath->SetName(GetName(myCurveBlocks[i].myName));
+ theEntities.Append(aBath);
+ }
}
if (myCurveBlocks[i].myType == 1 || myCurveBlocks[i].myType == 3) // XYZ curve or isocontour
{
- NCollection_Sequence<gp_XYZ> aPoints;
- for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+ if (!importOptions || (importOptions && (*importOptions)[i].ImportAsPolyXY == true))
{
- gp_XYZ aLocalPoint = gp_XYZ (myCurveBlocks[i].myXYZPoints[j]);
- theDocument->Transform(aLocalPoint, true);
- aPoints.Append(aLocalPoint);
- }
- /*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,
- 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(GetName(myCurveBlocks[i].myName));
- aProfileUZ->SetName(GetName(myCurveBlocks[i].myName));
- aProfile->SetName(GetName(myCurveBlocks[i].myName));
- aPolyXY->SetWireColor(HYDROData_PolylineXY::DefaultWireColor());
- theEntities.Append(aPolyXY);
- theEntities.Append(aProfileUZ);
- theEntities.Append(aProfile);
+ NCollection_Sequence<gp_XYZ> aPoints;
+ for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
+ {
+ gp_XYZ aLocalPoint = gp_XYZ (myCurveBlocks[i].myXYZPoints[j]);
+ theDocument->Transform(aLocalPoint, true);
+ aPoints.Append(aLocalPoint);
+ }
+
+ 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,
+ myCurveBlocks[i].myIsClosed ? true : false);
+ aPolyXY->SetName(GetName(myCurveBlocks[i].myName));
+ aPolyXY->SetWireColor(HYDROData_PolylineXY::DefaultWireColor());
+
+ for ( int k = 1; k <= aPoints.Size(); k++ ) {
+ const HYDROData_Profile::ProfilePoint& aBottomPoint = aPoints.Value( k );
+ aPolyXY->AddPoint( 0, HYDROData_PolylineXY::Point( aBottomPoint.X(), aBottomPoint.Y() ) );
+ }
+
+ theEntities.Append(aPolyXY);
+ if (!importOptions || (importOptions && (*importOptions)[i].ImportAsProfile == true))
+ {
+ Handle(HYDROData_ProfileUZ) aProfileUZ = Handle(HYDROData_ProfileUZ)::DownCast( theDocument->CreateObject( KIND_PROFILEUZ ) );
+ aProfileUZ->CalculateAndAddPoints(aPoints, aPolyXY, false);
+ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( theDocument->CreateObject( KIND_PROFILE ) );
+ aProfile->SetParametricPoints(aProfileUZ->GetPoints());
+
+ aProfileUZ->SetName(GetName(myCurveBlocks[i].myName));
+ aProfile->SetName(GetName(myCurveBlocks[i].myName));
+
+ theEntities.Append(aProfileUZ);
+ theEntities.Append(aProfile);
+ }
+ }
+
}
if (myCurveBlocks[i].myType == 2) // XYZ profile
{
- if (myCurveBlocks[i].myCurvePlane == 2) // plane XoZ
+ if (!importOptions || (importOptions && (*importOptions)[i].ImportAsProfile == true))
{
- if (myCurveBlocks[i].myAdditionalCurveInfo.size() == 4)
+ if (myCurveBlocks[i].myCurvePlane == 2) // plane XoZ
+ {
+ if (myCurveBlocks[i].myAdditionalCurveInfo.size() == 4)
+ {
+ Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( theDocument->CreateObject( KIND_PROFILE ) );
+ 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) )
+ { // georeferenced profile
+ double xl = myCurveBlocks[i].myAdditionalCurveInfo[0];
+ double yl = myCurveBlocks[i].myAdditionalCurveInfo[1];
+ double xr = myCurveBlocks[i].myAdditionalCurveInfo[2];
+ double yr = myCurveBlocks[i].myAdditionalCurveInfo[3];
+ theDocument->Transform(xl, yl , true);
+ theDocument->Transform(xr, yr , true);
+ aProfile->SetLeftPoint(gp_XY(xl, yl));
+ aProfile->SetRightPoint(gp_XY(xr, yr));
+ aProfile->Update();
+ }
+ aProfile->SetName(GetName(myCurveBlocks[i].myName));
+ theEntities.Append(aProfile);
+ }
+ }
+ if (myCurveBlocks[i].myCurvePlane == 0) // plane XoY
{
Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( theDocument->CreateObject( KIND_PROFILE ) );
- HYDROData_ProfileUZ::PointsList aPointList;
+ HYDROData_Profile::ProfilePoints 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()));
+ {
+ gp_XYZ aLocalPoint = gp_XYZ (myCurveBlocks[i].myXYZPoints[j]);
+ theDocument->Transform(aLocalPoint, true);
+ aPointList.Append(aLocalPoint);
+ }
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) )
- { // georeferenced profile
- double xl = myCurveBlocks[i].myAdditionalCurveInfo[0];
- double yl = myCurveBlocks[i].myAdditionalCurveInfo[1];
- double xr = myCurveBlocks[i].myAdditionalCurveInfo[2];
- double yr = myCurveBlocks[i].myAdditionalCurveInfo[3];
- theDocument->Transform(xl, yl , true);
- theDocument->Transform(xr, yr , true);
- aProfile->SetLeftPoint(gp_XY(xl, yl));
- aProfile->SetRightPoint(gp_XY(xr, yr));
- aProfile->Update();
- }
+ aProfile->SetProfilePoints(aPointList);
aProfile->SetName(GetName(myCurveBlocks[i].myName));
theEntities.Append(aProfile);
}
}
- if (myCurveBlocks[i].myCurvePlane == 0) // plane XoY
- {
- Handle(HYDROData_Profile) aProfile = Handle(HYDROData_Profile)::DownCast( theDocument->CreateObject( KIND_PROFILE ) );
- HYDROData_Profile::ProfilePoints aPointList;
- for (size_t j = 0; j < myCurveBlocks[i].myXYZPoints.size(); j++)
- {
- gp_XYZ aLocalPoint = gp_XYZ (myCurveBlocks[i].myXYZPoints[j]);
- theDocument->Transform(aLocalPoint, true);
- aPointList.Append(aLocalPoint);
- }
- 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(GetName(myCurveBlocks[i].myName));
- theEntities.Append(aProfile);
- }
}
}
}
}
}
+
+std::vector<HYDROGUI_CurveBlock> HYDROData_SinusX::GetCurveBlocks() const
+{
+ return myCurveBlocks;
+}
+
+
#define HYDRODATA_SINUSX_H
#include <vector>
+#include <utility>
#include <HYDROData.h>
#include <NCollection_Sequence.hxx>
#include <QString>
class HYDRODATA_EXPORT HYDROData_SinusX
{
+public:
+ struct ImportOptions
+ {
+ ImportOptions() : ImportAsBathy(false), ImportAsProfile(false), ImportAsPolyXY(false)
+ {};
+ bool ImportAsBathy;
+ bool ImportAsProfile;
+ bool ImportAsPolyXY;
+ };
public:
HYDROData_SinusX( );
virtual ~HYDROData_SinusX();
- bool Import (const QString& theFilePath, Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
+
+ bool OpenAndParse(const QString& theFilePath);
+ void Import(Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
+ std::vector<ImportOptions>* importOptions = NULL);
+
bool Export(const QString& theFilePath, const NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
+ std::vector<HYDROGUI_CurveBlock> GetCurveBlocks() const;
private:
- void SXToHydro(Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities);
+ void SXToHydro(Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle(HYDROData_Entity)>& theEntities,
+ std::vector<ImportOptions>* importOptions);
bool Parse( QFile& theFile );
void CollectExistingNames(Handle(HYDROData_Document) theDocument);
QString GetName(const QString& theName);
aProfileUZ->RemoveSection( 0 );
- aProfileUZ->CalculateAndAddPoints(aBottomPoints, aPolylineXY);
+ aProfileUZ->CalculateAndAddPoints(aBottomPoints, aPolylineXY, true);
return true;
}
HYDROGUI_MeasurementToolDlg.h
HYDROGUI_SIProgressIndicator.h
HYDROGUI_ZIProgressIndicator.h
+ HYDROGUI_ImportPolylineDlg.h
+ HYDROGUI_ImportSinusXDlg.h
)
QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_MeasurementToolDlg.cxx
HYDROGUI_SIProgressIndicator.cxx
HYDROGUI_ZIProgressIndicator.cxx
+ HYDROGUI_ImportPolylineDlg.cxx
+ HYDROGUI_ImportSinusXDlg.cxx
)
add_definitions(
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ImportPolylineDlg.h"
+#include <QVBoxLayout>
+#include <QPushButton>
+#include <QLabel>
+
+HYDROGUI_ImportPolylineDlg::HYDROGUI_ImportPolylineDlg( QWidget* theParent,
+ const NCollection_Sequence<Handle(HYDROData_Entity)>& PolyEnts )
+ : QDialog( theParent )
+{
+ QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+ aMainLayout->setMargin(5);
+ aMainLayout->setSpacing(5);
+
+ QLabel* gLabel = new QLabel();
+ gLabel->setText(tr("POLYLINES_3D_IN_FILES"));
+
+ myPolylineTable = new QTableWidget(PolyEnts.Size(), 2);
+
+ myPolyEnts = PolyEnts;
+
+ QStringList header;
+ header << tr("POLYLINE_NAME") << tr("FULL_IMPORT");
+ myPolylineTable->setHorizontalHeaderLabels(header);
+ myPolylineTable->setShowGrid(true);
+
+ for (int i = 1; i <= myPolyEnts.Size(); i++)
+ {
+ QTableWidgetItem* item = new QTableWidgetItem(myPolyEnts(i)->GetName());
+ item->setFlags(item->flags() ^ Qt::ItemIsEditable);
+ myPolylineTable->setItem(i-1, 0, item);
+
+ QTableWidgetItem* itemCheckbox = new QTableWidgetItem("");
+ itemCheckbox->setFlags(itemCheckbox->flags() ^ Qt::ItemIsEditable);
+ itemCheckbox->setCheckState(Qt::Unchecked);
+ myPolylineTable->setItem(i-1, 1, itemCheckbox);
+ }
+
+ aMainLayout->addWidget(gLabel);
+ aMainLayout->addWidget(myPolylineTable);
+
+ QPushButton* CheckAllButton = new QPushButton( tr("CHECK_ALL"), this );
+ QPushButton* UncheckAllButton = new QPushButton( tr("UNCHECK_ALL"), this );
+
+ QPushButton* anOkButton = new QPushButton( tr("OK"), this );
+ anOkButton->setDefault( true );
+
+ aMainLayout->addWidget( CheckAllButton );
+ aMainLayout->addWidget( UncheckAllButton );
+ aMainLayout->addWidget( anOkButton );
+
+ connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ connect( CheckAllButton, SIGNAL( clicked() ), this, SLOT( onCheckAll() ) );
+ connect( UncheckAllButton, SIGNAL( clicked() ), this, SLOT( onUncheckAll() ) );
+
+ setLayout(aMainLayout);
+}
+
+HYDROGUI_ImportPolylineDlg::~HYDROGUI_ImportPolylineDlg()
+{
+}
+
+void HYDROGUI_ImportPolylineDlg::onCheckAll()
+{
+ for (int i = 1; i <= myPolyEnts.Size(); i++)
+ {
+ QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
+ itemCheckbox->setCheckState(Qt::Checked);
+ }
+}
+
+void HYDROGUI_ImportPolylineDlg::onUncheckAll()
+{
+ for (int i = 1; i <= myPolyEnts.Size(); i++)
+ {
+ QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
+ itemCheckbox->setCheckState(Qt::Unchecked);
+ }
+}
+
+NCollection_Sequence<Handle(HYDROData_Entity)> HYDROGUI_ImportPolylineDlg::GetCheckedPolylines() const
+{
+ NCollection_Sequence<Handle(HYDROData_Entity)> checkedPolys;
+ for (int i = 1; i <= myPolyEnts.Size(); i++)
+ {
+ QTableWidgetItem* itemCheckbox = myPolylineTable->item(i-1, 1);
+ if (itemCheckbox->checkState() == Qt::CheckState::Checked)
+ checkedPolys.Append(myPolyEnts(i));
+ }
+ return checkedPolys;
+}
+
+
+
+
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+
+
+#ifndef HYDROGUI_IMPORTPOLYLINEDLG_H
+#define HYDROGUI_IMPORTPOLYLINEDLG_H
+
+#include <QTableWidget>
+#include <QDialog>
+#include <NCollection_Sequence.hxx>
+#include <HYDROData_Entity.h>
+
+class HYDROGUI_ImportPolylineDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ HYDROGUI_ImportPolylineDlg( QWidget* theParent, const NCollection_Sequence<Handle(HYDROData_Entity)>& PolyEnts );
+ virtual ~HYDROGUI_ImportPolylineDlg();
+
+ NCollection_Sequence<Handle(HYDROData_Entity)> GetCheckedPolylines() const;
+
+private slots:
+ void onCheckAll();
+ void onUncheckAll();
+
+private:
+ QTableWidget* myPolylineTable;
+ NCollection_Sequence<Handle(HYDROData_Entity)> myPolyEnts;
+
+};
+
+#endif
#include <QFileInfo>
#include <SUIT_MessageBox.h>
#include <gp_XY.hxx>
-
+#include <HYDROGUI_ImportPolylineDlg.h>
+#include <HYDROGUI_Module.h>
+#include <HYDROGUI_Operation.h>
HYDROGUI_ImportPolylineOp::HYDROGUI_ImportPolylineOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule )
}
if (anExt == "shp")
{
+ QApplication::setOverrideCursor( Qt::WaitCursor );
HYDROData_ShapeFile anImporter;
- NCollection_Sequence<Handle(HYDROData_Entity)> theEntities;
+ NCollection_IndexedDataMap<Handle(HYDROData_Entity), SHPObject*> theEntitiesToSHPObj;
+ NCollection_Sequence<Handle(HYDROData_Entity)> PolyEnt;
int aShapeTypeOfFile = -1;
- int aStat = anImporter.ImportPolylines(theDocument, aFileName, theEntities,
- aShapeTypeOfFile, theShapeTypesToImport );
+ int aStat = anImporter.OpenAndParse(aFileName);
+ QApplication::restoreOverrideCursor();
+ if (aStat == 1)
+ {
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ aStat = anImporter.ImportPolylines(theDocument, aFileName, theEntitiesToSHPObj, theShapeTypesToImport);
+ QApplication::restoreOverrideCursor();
+ for (int k=1;k<=theEntitiesToSHPObj.Extent();k++)
+ {
+ PolyEnt.Append(theEntitiesToSHPObj.FindKey(k));
+ }
if (aStat == 1 || aStat == 2)
{
//try to import DBF
{
QStringList aFieldList = anImporter.DBF_GetFieldList();
int nbRecords = anImporter.DBF_GetNbRecords();
- assert (theEntities.Length() == nbRecords);
- if (theEntities.Length() == nbRecords)
+ assert (theEntitiesToSHPObj.Extent() == nbRecords);
+ if (theEntitiesToSHPObj.Extent() == nbRecords)
{
int indNameAttrFound = -1;
int k = 0;
}
int indNULL = 1;
- for (int i = 1; i <= theEntities.Length(); i++)
+ for (int i = 1; i <= theEntitiesToSHPObj.Extent(); i++)
{
- Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theEntities(i) );
+ Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theEntitiesToSHPObj.FindKey(i) );
QStringList aDBFinfo;
aDBFinfo << aFieldList; //first, the table header
for (int j = 0; j < aFieldList.size(); j++)
}
}
}
+
+ if (anImporter.GetShapeType() == 13) //Polyline 3D
+ {
+ HYDROGUI_ImportPolylineDlg* aDLG = new HYDROGUI_ImportPolylineDlg( module->getApp()->desktop(), PolyEnt );
+ aDLG->setModal( true );
+ aDLG->setWindowTitle(tr("IMPORT_POLYLINE"));
+ //QApplication::restoreOverrideCursor();
+ if( aDLG->exec()==QDialog::Accepted )
+ {
+ NCollection_Sequence<Handle(HYDROData_Entity)> CheckedPolylines = aDLG->GetCheckedPolylines();
+ NCollection_IndexedDataMap<Handle(HYDROData_Entity), SHPObject*> CheckedEntitiesToSHPObj;
+ for (int k=1;k<=CheckedPolylines.Size();k++)
+ {
+ SHPObject* const* SHPObkP = theEntitiesToSHPObj.Seek(CheckedPolylines(k));
+ if (SHPObkP != NULL)
+ CheckedEntitiesToSHPObj.Add(CheckedPolylines(k), *SHPObkP);
+ }
+ NCollection_Sequence<Handle(HYDROData_Entity)> theEntitiesPoly3D;
+ anImporter.ImportPolylines3D(theDocument, CheckedEntitiesToSHPObj, theEntitiesPoly3D, theShapeTypesToImport);
+ PolyEnt.Append(theEntitiesPoly3D);
+ }
+ }
+ anImporter.Free();
+ }
if (aStat == 1)
- UpdateView(module, theEntities);
+ UpdateView(module, PolyEnt);
else if (aStat == 2)
{
- UpdateView(module, theEntities);
+ UpdateView(module, PolyEnt);
if (theShapeTypesToImport == HYDROData_ShapeFile::ImportShapeType_All) //if other flag = > no need to show this messagebox
SUIT_MessageBox::information(module->getApp()->desktop(),
tr( "IMPORT_POLYLINE" ), tr ("POLYGON_IMPORTED_AS_POLYLINE"));
aMess += tr ("SHAPE_TYPE_IS") + anImporter.GetShapeTypeName(aShapeTypeOfFile);
SUIT_MessageBox::warning( module->getApp()->desktop(), tr( "IMPORT_POLYLINE" ), aMess);
}
- importedEntities.Append(theEntities);
+ importedEntities.Append(PolyEnt);
}
else if ( anExt == "xy" || (importXY && anExt == "xyz"))
{
QStringList aFileNames = myFileDlg->selectedFiles();
- QApplication::setOverrideCursor( Qt::WaitCursor );
+ //QApplication::setOverrideCursor( Qt::WaitCursor );
startDocOperation();
ImportPolyOp(aFileNames, doc(), module(), HYDROData_ShapeFile::ImportShapeType_All);
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "HYDROGUI_ImportSinusXDlg.h"
+#include <QVBoxLayout>
+#include <QPushButton>
+#include <QLabel>
+#include <HYDROData_SinusX.h>
+#include <assert.h>
+#include <QHeaderView>
+#include <QSizePolicy>
+
+HYDROGUI_ImportSinusXDlg::HYDROGUI_ImportSinusXDlg( QWidget* theParent, const QStringList& theNames,
+ const std::vector<int>& theTypes )
+ : QDialog( theParent )
+{
+ QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+ aMainLayout->setMargin(5);
+ aMainLayout->setSpacing(5);
+ this->resize(600, 500);
+
+ QLabel* gLabel = new QLabel();
+ gLabel->setText(tr("ENTITIES_TO_IMPORT"));
+
+ assert (theNames.size() == theTypes.size());
+ myTable = new QTableWidget(theNames.size(), 5);
+
+ QStringList header;
+ header << tr("NAME") << tr("TYPE") << tr("AS_BATHY") << tr("AS_POLYXY") << tr("AS_PROFILE");
+ myTable->setHorizontalHeaderLabels(header);
+
+ myTable->setShowGrid(true);
+ myTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch);
+
+ for (int i = 0; i < theNames.size(); i++)
+ {
+ QTableWidgetItem* item_name = new QTableWidgetItem(theNames[i]);
+ item_name->setFlags(item_name->flags() ^ Qt::ItemIsEditable);
+ myTable->setItem(i, 0, item_name);
+
+ QString TypeName;
+ if (theTypes[i] == 1)
+ TypeName = tr("XYZ_CURVE");
+ else if (theTypes[i] == 2)
+ TypeName = tr("XYZ_PROFILE");
+ else if (theTypes[i] == 3)
+ TypeName = tr("ISOCONTOUR");
+ else if (theTypes[i] == 4)
+ TypeName = tr("SCATTER");
+
+ QTableWidgetItem* item_type = new QTableWidgetItem(TypeName);
+ item_type->setFlags(item_type->flags() ^ Qt::ItemIsEditable);
+ myTable->setItem(i, 1, item_type);
+
+ QTableWidgetItem* itemCheckbox1 = new QTableWidgetItem(""); //as bathy
+ itemCheckbox1->setFlags(itemCheckbox1->flags() ^ Qt::ItemIsEditable);
+ itemCheckbox1->setCheckState(Qt::Checked);
+ myTable->setItem(i, 2, itemCheckbox1);
+
+ QTableWidgetItem* itemCheckbox2 = new QTableWidgetItem(""); ; //as polyXY
+ itemCheckbox2->setFlags(itemCheckbox2->flags() ^ Qt::ItemIsEditable);
+ itemCheckbox2->setCheckState(Qt::Checked);
+ myTable->setItem(i, 3, itemCheckbox2);
+
+ QTableWidgetItem* itemCheckbox3 = new QTableWidgetItem(""); ; //as profile
+ itemCheckbox3->setFlags(itemCheckbox3->flags() ^ Qt::ItemIsEditable);
+ itemCheckbox3->setCheckState(Qt::Checked);
+ myTable->setItem(i, 4, itemCheckbox3);
+
+ if (theTypes[i] == 1 || theTypes[i] == 3) ///XYZ curve
+ {
+ itemCheckbox1->setFlags(item_type->flags() & ~Qt::ItemIsEnabled); //disable bathy
+ itemCheckbox1->setCheckState(Qt::Unchecked);
+ }
+ else if (theTypes[i] == 2)
+ {
+ itemCheckbox1->setFlags(item_type->flags() & ~Qt::ItemIsEnabled);
+ itemCheckbox2->setFlags(item_type->flags() & ~Qt::ItemIsEnabled);
+ itemCheckbox1->setCheckState(Qt::Unchecked);
+ itemCheckbox2->setCheckState(Qt::Unchecked);
+ }
+ else if (theTypes[i] == 4)
+ {
+ //as bathy only
+ itemCheckbox2->setFlags(item_type->flags() & ~Qt::ItemIsEnabled);
+ itemCheckbox3->setFlags(item_type->flags() & ~Qt::ItemIsEnabled);
+ itemCheckbox2->setCheckState(Qt::Unchecked);
+ itemCheckbox3->setCheckState(Qt::Unchecked);
+ }
+ }
+
+ aMainLayout->addWidget(gLabel);
+ aMainLayout->addWidget(myTable);
+
+ //QPushButton* CheckAllButton = new QPushButton( tr("CHECK_ALL"), this );
+ //QPushButton* UncheckAllButton = new QPushButton( tr("UNCHECK_ALL"), this );
+
+ QPushButton* anOkButton = new QPushButton( tr("OK"), this );
+ anOkButton->setDefault( true );
+
+ //aMainLayout->addWidget( CheckAllButton );
+ //aMainLayout->addWidget( UncheckAllButton );
+ aMainLayout->addWidget( anOkButton );
+
+ connect( anOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) );
+ //connect( CheckAllButton, SIGNAL( clicked() ), this, SLOT( onCheckAll() ) );
+ //connect( UncheckAllButton, SIGNAL( clicked() ), this, SLOT( onUncheckAll() ) );
+
+ connect(myTable, SIGNAL(cellChanged(int,int)), this, SLOT(onCheckChecked(int, int)));
+
+ setLayout(aMainLayout);
+}
+
+HYDROGUI_ImportSinusXDlg::~HYDROGUI_ImportSinusXDlg()
+{
+}
+
+void HYDROGUI_ImportSinusXDlg::onCheckChecked(int r, int c)
+{
+ ///if it's "as POLYLINE" column and now it's unchecked => disable "as PROFILE" checkbox
+ if (c == 3 && myTable->item(r, 3)->checkState() == Qt::Unchecked)
+ {
+ QString text = myTable->item(r, 1)->text();
+ if (text == tr("XYZ_CURVE") || text == tr("ISOCONTOUR"))
+ myTable->item(r, 4)->setCheckState(Qt::Unchecked);
+ }
+}
+
+std::vector<HYDROData_SinusX::ImportOptions> HYDROGUI_ImportSinusXDlg::GetImportOptions() const
+{
+ std::vector<HYDROData_SinusX::ImportOptions> options;
+ int size = myTable->rowCount();
+ for (int i = 0; i < size; i++)
+ {
+ HYDROData_SinusX::ImportOptions option;
+ if (myTable->item(i, 2)->checkState() == Qt::CheckState::Checked)
+ option.ImportAsBathy = true;
+ if (myTable->item(i, 3)->checkState() == Qt::CheckState::Checked)
+ option.ImportAsPolyXY = true;
+ if (myTable->item(i, 4)->checkState() == Qt::CheckState::Checked)
+ option.ImportAsProfile = true;
+ options.push_back(option);
+ }
+ return options;
+}
+
+
+
+
--- /dev/null
+// Copyright (C) 2014-2015 EDF-R&D
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+
+
+#ifndef HYDROGUI_IMPORTSINUSXDLG_H
+#define HYDROGUI_IMPORTSINUSXDLG_H
+
+#include <QTableWidget>
+#include <QDialog>
+#include <NCollection_Sequence.hxx>
+#include <HYDROData_Entity.h>
+#include <HYDROData_SinusX.h>
+
+class HYDROGUI_ImportSinusXDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ HYDROGUI_ImportSinusXDlg( QWidget* theParent, const QStringList& theNames,
+ const std::vector<int>& theTypes);
+ virtual ~HYDROGUI_ImportSinusXDlg();
+
+ std::vector<HYDROData_SinusX::ImportOptions> GetImportOptions() const;
+
+private slots:
+ void onCheckChecked(int r, int c);
+
+ //private slots:
+// void onCheckAll();
+// void onUncheckAll();
+
+private:
+ QTableWidget* myTable;
+ //NCollection_Sequence<Handle(HYDROData_Entity)> myPolyEnts;
+};
+
+#endif
#include <QMessageBox>
#include <HYDROData_SinusX.h>
+#include <HYDROGUI_ImportSinusXDlg.h>
HYDROGUI_ImportSinusXOp::HYDROGUI_ImportSinusXOp( HYDROGUI_Module* theModule )
QStringList aFileNames = myFileDlg->selectedFiles();
bool IsImported = false;
-
- QApplication::setOverrideCursor( Qt::WaitCursor );
+
startDocOperation();
foreach (QString aFileName, aFileNames)
{
HYDROData_SinusX aSinusXImporter;
NCollection_Sequence<Handle(HYDROData_Entity)> anEntities;
- if (aSinusXImporter.Import(aFileName, doc(), anEntities))
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ bool ParseStat = aSinusXImporter.OpenAndParse(aFileName);
+ QApplication::restoreOverrideCursor();
+ if (ParseStat)
{
- UpdateView(anEntities);
- IsImported = true;
+ std::vector<HYDROGUI_CurveBlock> aCurveBlocks = aSinusXImporter.GetCurveBlocks();
+ QStringList names;
+ std::vector<int> types;
+ for (int i=0;i<aCurveBlocks.size();i++)
+ {
+ HYDROGUI_CurveBlock CurveBlock = aCurveBlocks[i];
+ types.push_back(CurveBlock.myType);
+ names << CurveBlock.myName;
+ }
+ HYDROGUI_ImportSinusXDlg* aDLG = new HYDROGUI_ImportSinusXDlg( module()->getApp()->desktop(), names, types );
+ aDLG->setModal( true );
+ aDLG->setWindowTitle(tr("ENTITIES_TO_IMPORT_FROM_SX"));
+ //QApplication::restoreOverrideCursor();
+ if( aDLG->exec()==QDialog::Accepted ) //??
+ {
+ QApplication::setOverrideCursor( Qt::WaitCursor );
+ std::vector<HYDROData_SinusX::ImportOptions> options = aDLG->GetImportOptions();
+ aSinusXImporter.Import(doc(), anEntities, &options);
+ UpdateView(anEntities);
+ QApplication::restoreOverrideCursor();
+ IsImported = true;
+ }
}
}
}
<source>NO_ONE_ENTITY_IMPORTED</source>\r
<translation>Entities cant be read</translation>\r
</message>\r
+ <message>\r
+ <source>ENTITIES_TO_IMPORT_FROM_SX</source>\r
+ <translation>SinusX file entities</translation>\r
+ </message>\r
+\r
</context>\r
\r
<context>\r
<translation>Measurement Tool</translation>\r
</message>\r
</context>\r
+\r
+ <context>\r
+ <name>HYDROGUI_ImportSinusXDlg</name>\r
+ <message>\r
+ <source>ENTITIES_TO_IMPORT</source>\r
+ <translation>The file contains the entities listed below. Check the entities which you wish to import and their importing type</translation>\r
+ </message>\r
+ <message>\r
+ <source>NAME</source>\r
+ <translation>Entity name</translation>\r
+ </message>\r
+ <message>\r
+ <source>TYPE</source>\r
+ <translation>Type</translation>\r
+ </message>\r
+ <message>\r
+ <source>AS_BATHY</source>\r
+ <translation>As bathymetry</translation>\r
+ </message>\r
+ <message>\r
+ <source>AS_BATHY</source>\r
+ <translation>As bathymetry</translation>\r
+ </message>\r
+ <message>\r
+ <source>AS_POLYXY</source>\r
+ <translation>As PolylineXY</translation>\r
+ </message>\r
+ <message>\r
+ <source>AS_BATHY</source>\r
+ <translation>As bathymetry</translation>\r
+ </message>\r
+ <message>\r
+ <source>AS_PROFILE</source>\r
+ <translation>As profile</translation>\r
+ </message>\r
+ <message>\r
+ <source>XYZ_CURVE</source>\r
+ <translation>XYZ curve</translation>\r
+ </message>\r
+ <message>\r
+ <source>XYZ_PROFILE</source>\r
+ <translation>XYZ profile</translation>\r
+ </message>\r
+ <message>\r
+ <source>ISOCONTOUR</source>\r
+ <translation>Isocontour</translation>\r
+ </message>\r
+ <message>\r
+ <source>SCATTER</source>\r
+ <translation>Scatter plot</translation>\r
+ </message>\r
+ <message>\r
+ <source>OK</source>\r
+ <translation>Ok</translation>\r
+ </message>\r
+ </context>\r
\r
<context>\r
<name>HYDROGUI_SIProgressIndicator</name>\r
</message>\r
</context>\r
\r
+\r
+ <context>\r
+ <name>HYDROGUI_ImportPolylineDlg</name>\r
+ <message>\r
+ <source>POLYLINES_3D_IN_FILES</source>\r
+ <translation>The shp file contains polyline3D objects (ARCZ). \r
+They have been imported as polylineXY only, \r
+but can be imported with Z part (additional profile and bathymetry). \r
+If checkbox of corresponding polyline in the table below is checked \r
+then it will be imported with Z part, otherwise as PolylineXY only</translation>\r
+ </message>\r
+ <message>\r
+ <source>POLYLINE_NAME</source>\r
+ <translation>Polyline name</translation>\r
+ </message>\r
+ <message>\r
+ <source>FULL_IMPORT</source>\r
+ <translation>Full import</translation>\r
+ </message>\r
+ <message>\r
+ <source>CHECK_ALL</source>\r
+ <translation>Check all</translation>\r
+ </message>\r
+ <message>\r
+ <source>UNCHECK_ALL</source>\r
+ <translation>Uncheck all</translation>\r
+ </message>\r
+ <message>\r
+ <source>OK</source>\r
+ <translation>Ok</translation>\r
+ </message>\r
+\r
+ </context>\r
+\r
+\r
</TS>\r