bool HYDROData_LandCoverMap::IsEmpty() const
{
Iterator anIt( *this );
- if ( anIt.More() )
+ if ( !anIt.More() )
return true;
else
return false;
void HYDROData_ShapeFile::Export(const QString& aFileName,
NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq,
NCollection_Sequence<Handle_HYDROData_Polyline3D> aPoly3DSeq,
- const Handle_HYDROData_LandCoverMap& aLCM,
QStringList& aNonExpList)
{
SHPHandle hSHPHandle;
for (int i = 1; i <= aPolyXYSeq.Size(); i++)
if (WriteObjectPolyXY(hSHPHandle, aPolyXYSeq(i)) != 1)
aNonExpList.append(aPolyXYSeq(i)->GetName());
-
}
else if (aPolyXYSeq.IsEmpty() && !aPoly3DSeq.IsEmpty())
{
if (WriteObjectPoly3D(hSHPHandle, aPoly3DSeq(i)) != 1)
aNonExpList.append(aPoly3DSeq(i)->GetName());
}
- else if (aPolyXYSeq.IsEmpty() && aPoly3DSeq.IsEmpty() && !aLCM->IsEmpty())
+ if (hSHPHandle->nRecords > 0)
+ SHPClose( hSHPHandle );
+ else
+ {
+ SHPClose( hSHPHandle );
+ QString aFN = aFileName.simplified();
+ remove (aFN.toStdString().c_str());
+ remove (aFN.replace( ".shp", ".shx", Qt::CaseInsensitive).toStdString().c_str());
+ }
+}
+
+void HYDROData_ShapeFile::Export(const QString& aFileName,
+ const Handle_HYDROData_LandCoverMap& aLCM, QStringList& aNonExpList)
+{
+ SHPHandle hSHPHandle;
+ if ( !aLCM.IsNull() && !aLCM->IsEmpty())
{
hSHPHandle = SHPCreate( aFileName.toAscii().data(), SHPT_POLYGON );
HYDROData_LandCoverMap::Iterator It( aLCM );
if (WriteObjectPolygon(hSHPHandle, aFace) != 1)
aNonExpList.append(aLCM->GetName() + "_" + QString::number(It.Index()));
}
- /*for (int i = 1; i <= aLCSeq.Size(); i++)
- if (WriteObjectLC(hSHPHandle, aLCSeq(i)) != 1)
- aNonExpList.append(aLCSeq(i)->GetName());*/
}
if (hSHPHandle->nRecords > 0)
SHPClose( hSHPHandle );
}
}
+
int HYDROData_ShapeFile::WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly )
{
SHPObject *aSHPObj;
HYDRODATA_EXPORT void Export(const QString& aFileName,
NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq,
NCollection_Sequence<Handle_HYDROData_Polyline3D> aPoly3DSeq,
+ QStringList& aNonExpList);
+
+ HYDRODATA_EXPORT void Export(const QString& aFileName,
const Handle_HYDROData_LandCoverMap& aLCM,
QStringList& aNonExpList);
+
int WriteObjectPolyXY(SHPHandle theShpHandle, Handle_HYDROData_PolylineXY thePoly );
+
int WriteObjectPoly3D(SHPHandle theShpHandle, Handle_HYDROData_Polyline3D thePoly );
+
int WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS_Shape& theInputShape );
//Import
bool Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile);
//Import Landcover
void ReadSHPPolygon(SHPObject* anObj, int i, TopoDS_Face& F);
- HYDRODATA_EXPORT int ImportPolygons(const QString theFileName, QStringList& thePolygonsList, TopTools_SequenceOfShape& theFaces, int& theShapeTypeOfFile);
+
+ HYDRODATA_EXPORT int ImportPolygons(const QString theFileName,
+ QStringList& thePolygonsList,
+ TopTools_SequenceOfShape& theFaces,
+ int& theShapeTypeOfFile);
+
HYDRODATA_EXPORT void Free();
+
//Import Polyline
void ReadSHPPolyXY(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
- int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+ int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+
void ReadSHPPoly3D(Handle(HYDROData_Document) theDocument, SHPObject* anObj, QString theFileName,
- int theInd, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+ int theInd, 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_Sequence<Handle_HYDROData_Entity>& theEntities, int& theShapeTypeOfFile);
+
HYDRODATA_EXPORT QString GetShapeTypeName(int theType);
//DBF I/O Methods
private:
void ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle);
+
int TryOpenShapeFile(QString theFileName);
+
private:
std::vector<SHPObject*> mySHPObjects;
SHPHandle myHSHP;
Handle(HYDROData_Polyline3D) aPoly3D;
NCollection_Sequence<Handle_HYDROData_PolylineXY> aPolyXYSeq;
NCollection_Sequence<Handle_HYDROData_Polyline3D> aPoly3DSeq;
- // TODO
- Handle_HYDROData_LandCoverMap aLCSeq;
-
+ //
HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( module() );
for( int anIndex = 1, aLength = aSeq.Length(); anIndex <= aLength; anIndex++ )
{
{
QStringList aNonExpList;
HYDROData_ShapeFile anExporter;
- // TODO
- anExporter.Export(aFileName, aPolyXYSeq, aPoly3DSeq, aLCSeq, aNonExpList);
+ if (!aPolyXYSeq.IsEmpty() || !aPolyXYSeq.IsEmpty())
+ //Export polylines
+ anExporter.Export(aFileName, aPolyXYSeq, aPoly3DSeq, aNonExpList);
+ else
+ {
+ //Export polygons
+ //aSeq.Size() <= 1
+ Handle_HYDROData_LandCoverMap aLCM = Handle(HYDROData_LandCoverMap)::DownCast( aSeq(1) );
+ anExporter.Export(aFileName, aLCM, aNonExpList);
+ }
+
if (!aNonExpList.empty())
{
QString aMessage = tr("CANNOT_BE_EXPORTED") + "\n";
#include <HYDROData_LandCoverMap.h>
//TODO add definitions into TS file
+//TODO check if LCM name is already exists..
+//rename it
HYDROGUI_ImportLandCoverMapOp::HYDROGUI_ImportLandCoverMapOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule )
{
aPanel->setPolygonNames(QStringList());
aPanel->setObjectName("");
QApplication::restoreOverrideCursor();
- QString aMess = "Cannot import content of this file as land cover map;\n";
+ QString aMess = "Cannot import land cover;\n";
if (aStat == -1)
aMess += "Cannot open SHP file";
else if (aStat == -2)
if ( !aPanel )
return false;
- myLCM = Handle(HYDROData_LandCoverMap)::DownCast( doc()->CreateObject( KIND_LAND_COVER_MAP ) );
+ myLCM = Handle(HYDROData_LandCoverMap)::DownCast( doc()->CreateObject( KIND_LAND_COVER_MAP ) );
HYDROData_MapOfFaceToStricklerType aMapFace2ST;
QStringList aAttrV_T;
HYDROData_Iterator It( aDoc, KIND_STRICKLER_TABLE );
for( ; It.More(); It.Next() )
{
- Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( It.Current() );
+ Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( It.Current() );
+ QString TT = aStricklerTableObj->GetAttrName();
if ( !aStricklerTableObj.IsNull())
{
const QStringList& aStricklerList = aStricklerTableObj->GetTypes();
foreach (QString aStr, aStricklerList)
+ {
+ QString AttVal = aStricklerTableObj->GetAttrValue(aStr);
aSTSet << aStr;
+ }
}
}
}
theMenu->addAction( action( SplitLandCoverId ) );
theMenu->addAction( action( MergeLandCoverId ) );
theMenu->addSeparator();
+ //
+ theMenu->addAction( action( ExportToShapeFileID ) );
}
else if( anIsVisualState && anIsObjectBrowser )
{
}
bool anIsPoly = anIsPolyline || anIsPolyline3D;
- if ((anIsPoly && !anIsLandCoverMap) || (!anIsPoly && anIsLandCoverMap))
+ if (anIsPoly && !anIsLandCoverMap)
theMenu->addAction( action( ExportToShapeFileID ) );
// Add copy action