#include <QFileInfo>
#include <QString>
#include <QStringList>
+#include <QTextStream>
HYDROData_SinusX::HYDROData_SinusX( )
{
}
+bool HYDROData_SinusX::Export(const QString& theFilePath, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities)
+{
+ if ( theFilePath.isEmpty() )
+ {
+ return false;
+ }
+
+ QString anExt = theFilePath.split('.', QString::SkipEmptyParts).back();
+
+ if (anExt == "sx")
+ {
+ QFile aFile (theFilePath);
+
+ aFile.open(QIODevice::WriteOnly | QIODevice::Truncate | QIODevice::Text);
+
+ HydroToSX(aFile, theEntities);
+
+ aFile.close();
+
+ return true;
+ }
+ else
+ return false;
+
+}
+
+void HYDROData_SinusX::HydroToSX(QFile& theFile, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities)
+{
+ QTextStream aTextStream(&theFile);
+ aTextStream << "C Generated by HYDRO Module\n";
+ aTextStream << "C\n";
+
+ for (int i = 1; i <= theEntities.Size(); i++)
+ {
+ Handle_HYDROData_Entity anEnt = theEntities.Value(i);
+ if (anEnt->IsKind( STANDARD_TYPE(HYDROData_Bathymetry) ))
+ {
+ Handle(HYDROData_Bathymetry) aBathy = Handle(HYDROData_Bathymetry)::DownCast( anEnt );
+ HYDROData_Bathymetry::AltitudePoints anXYZPoints = aBathy->GetAltitudePoints();
+ aTextStream << "B S\n";
+ aTextStream << "CN " << aBathy->GetName() << "\n";
+ aTextStream << "CP 0 0\n";
+ aTextStream << "CP 0\n";
+ for (int j = 1; j <= anXYZPoints.Size(); j++)
+ aTextStream << " " << QString::number(anXYZPoints(j).X(), 'f', 3)
+ << " " << QString::number(anXYZPoints(j).Y(), 'f', 3)
+ << " " << QString::number(anXYZPoints(j).Z(), 'f', 3) << "\n";
+ }
+ }
+}
\ No newline at end of file
HYDROData_SinusX( );
virtual ~HYDROData_SinusX();
bool Import (const QString& theFilePath, Handle(HYDROData_Document) theDocument, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+ bool Export(const QString& theFilePath, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+
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);
+ void HydroToSX(QFile& theFile, NCollection_Sequence<Handle_HYDROData_Entity>& theEntities);
+
private:
std::vector<HYDROGUI_CurveBlock> myCurveBlocks;
#include <HYDROData_Profile.h>
#include <HYDROData_Entity.h>
#include <HYDROGUI_ObjListBox.h>
-#include <QMessageBox>
+#include <HYDROGUI_Operation.h>
+#include "HYDROGUI_Module.h"
+#include <HYDROData_SinusX.h>
+#include <SUIT_FileDlg.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
+
+#include <LightApp_Application.h>
+#include <QApplication>
HYDROGUI_ExportSinusXOp::HYDROGUI_ExportSinusXOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule )
void HYDROGUI_ExportSinusXOp::onExportItems()
{
+ QString aFilter( "*.sx" ); //temp ext-n; replace with filter; TODO
HYDROGUI_ExportSinusXDlg* aPanel = ::qobject_cast<HYDROGUI_ExportSinusXDlg*>( inputPanel() );
if ( !aPanel )
return;
- int T = aPanel->GetSelectedEntities().Size();
+ if (!aPanel->GetSelectedEntities().IsEmpty())
+ {
+ //Export selected items to SX file
+ QString aFileName = SUIT_FileDlg::getFileName( module()->getApp()->desktop(), "", aFilter, tr( "EXPORT_SINUSX" ), false );
+ HYDROData_SinusX anExporter;
+ anExporter.Export(aFileName, aPanel->GetSelectedEntities());
+ }
}