#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
#include <TDataStd_RealList.hxx>
#include <TDataStd_UAttribute.hxx>
+#include <TDataStd_ExtStringArray.hxx>
#include <TopoDS_Iterator.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
{
ImportShape( GetShape(), true, NULL );
}
+
+void HYDROData_PolylineXY::SetDBFInfo( const QStringList& theDBFTable )
+{
+ int i = 1;
+ Handle_TDataStd_ExtStringArray TExtStrArr =
+ TDataStd_ExtStringArray::Set( myLab.FindChild( DataTag_DBFTableInfo), 1, theDBFTable.size() );
+ foreach (QString val, theDBFTable)
+ {
+ std::string StdVal = val.toStdString();
+ const char* aCVal = StdVal.c_str();
+ TExtStrArr->SetValue(i, TCollection_ExtendedString(aCVal));
+ i++;
+ }
+}
+
+bool HYDROData_PolylineXY::GetDBFInfo(QStringList& theDBFTable) const
+{
+ TDF_Label aLabel = myLab.FindChild( DataTag_DBFTableInfo, false );
+ if ( !aLabel.IsNull() )
+ {
+ Handle(TDataStd_ExtStringArray) anExtStrArr;
+ if ( aLabel.FindAttribute( TDataStd_ExtStringArray::GetID(), anExtStrArr ) )
+ {
+ for (int i = anExtStrArr->Lower(); i <= anExtStrArr->Upper(); i++ )
+ {
+ Standard_ExtString str = anExtStrArr->Value(i).ToExtString();
+ TCollection_AsciiString aText (str);
+ theDBFTable << QString(aText.ToCString());
+ }
+ }
+ }
+ else
+ return false;
+ return true;
+}
{
DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
DataTag_GeomObjectEntry, ///< study entry of the imported GEOM object
+ DataTag_DBFTableInfo
};
public:
*/
HYDRODATA_EXPORT void Transform( const QTransform& theTrsf );
+ HYDRODATA_EXPORT void SetDBFInfo(const QStringList& theDBFTable);
+
+ HYDRODATA_EXPORT bool GetDBFInfo(QStringList& theDBFTable) const;
+
protected:
/**
HYDROGUI_ZoneTool.h
HYDROGUI_RegenerateRegionColorsOp.h
HYDROGUI_ZoneSetColorOp.h
+ HYDROGUI_PolyAttrDlg.h
+ HYDROGUI_ShowAttrPolyOp.h
)
QT_WRAP_MOC(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
HYDROGUI_ZoneTool.cxx
HYDROGUI_RegenerateRegionColorsOp.cxx
HYDROGUI_ZoneSetColorOp.cxx
+ HYDROGUI_PolyAttrDlg.cxx
+ HYDROGUI_ShowAttrPolyOp.cxx
)
add_definitions(
NCollection_Sequence<Handle(HYDROData_Entity)> theEntities;
int aShapeTypeOfFile = -1;
int aStat = anImporter.ImportPolylines(doc(), aFileName, theEntities, aShapeTypeOfFile );
+ if (aStat == 1 || aStat == 2)
+ {
+ //try to import DBF
+ QString aDBFFileName;
+ aDBFFileName = aFileName.simplified().replace( aFileName.simplified().size() - 4, 4, ".dbf");
+ bool DBF_Stat = anImporter.DBF_OpenDBF(aDBFFileName);
+ if (DBF_Stat)
+ {
+ QStringList aFieldList = anImporter.DBF_GetFieldList();
+ int nbRecords = anImporter.DBF_GetNbRecords();
+ assert (theEntities.Length() == nbRecords);
+ if (theEntities.Length() == nbRecords)
+ {
+ int indNameAttrFound = -1;
+ int k = 0;
+ bool bUseNameAttrFound = false;
+ for (QStringList::iterator it = aFieldList.begin(); it != aFieldList.end(); it++, k++)
+ if (QString::compare(*it, "name", Qt::CaseInsensitive) == 0)
+ {
+ indNameAttrFound = k;
+ break;
+ }
+
+ if (indNameAttrFound != -1)
+ bUseNameAttrFound = SUIT_MessageBox::question( module()->getApp()->desktop(),
+ tr( "IMPORT_POLYLINE" ),
+ tr( "IMPORT_POLYLINE_USE_NAME_ATTR" ),
+ QMessageBox::Yes | QMessageBox::No,
+ SUIT_MessageBox::Yes) == SUIT_MessageBox::Yes;
+
+ std::vector<std::vector<HYDROData_ShapeFile::DBF_AttrValue>> anAttrVV;
+ for (int i = 0; i < aFieldList.size(); i++)
+ {
+ std::vector<HYDROData_ShapeFile::DBF_AttrValue> anAttrV;
+ anAttrVV.push_back(anAttrV);
+ anImporter.DBF_GetAttributeList(i, anAttrVV[i] );
+ }
+
+ int indNULL = 1;
+ for (int i = 1; i <= theEntities.Length(); i++)
+ {
+ Handle(HYDROData_PolylineXY) aPolylineXY = Handle(HYDROData_PolylineXY)::DownCast( theEntities(i) );
+ QStringList aDBFinfo;
+ aDBFinfo << aFieldList; //first, the table header
+ for (int j = 0; j < aFieldList.size(); j++)
+ {
+ QString attr;
+ const HYDROData_ShapeFile::DBF_AttrValue& attrV = anAttrVV[j][i-1];
+ if (attrV.myFieldType == HYDROData_ShapeFile::DBF_FieldType_String)
+ aDBFinfo << attrV.myStrVal;
+ else if (attrV.myFieldType == HYDROData_ShapeFile::DBF_FieldType_Integer)
+ aDBFinfo << QString::number(attrV.myIntVal);
+ else if (attrV.myFieldType == HYDROData_ShapeFile::DBF_FieldType_Double)
+ aDBFinfo << QString::number(attrV.myDoubleVal);
+ else
+ aDBFinfo << "";
+ }
+ assert (aDBFinfo.size() / 2 == aFieldList.size());
+ aPolylineXY->SetDBFInfo(aDBFinfo);
+ if (bUseNameAttrFound)
+ {
+ QString nameOfPoly = aDBFinfo[aDBFinfo.size() / 2 + indNameAttrFound];
+ if (!nameOfPoly.isEmpty())
+ aPolylineXY->SetName(nameOfPoly);
+ else
+ {
+ aPolylineXY->SetName("null_name_" + QString::number(indNULL));
+ indNULL++;
+ }
+ }
+ }
+ }
+ }
+ }
if (aStat == 1)
UpdateView(theEntities);
else if (aStat == 2)
theMenu->addAction( action( SplitPolylinesId ) );
theMenu->addAction( action( MergePolylinesId ) );
theMenu->addSeparator();
+ theMenu->addAction( action( ShowAttrPolylinesId ) );
+ theMenu->addSeparator();
}
else if( anIsPolyline3D )
{
#include "HYDROGUI_RegenerateRegionColorsOp.h"
#include "HYDROGUI_PolylineStyleOp.h"
#include "HYDROGUI_ZoneSetColorOp.h"
+#include <HYDROGUI_ShowAttrPolyOp.h>
#include <HYDROData_Document.h>
#include <HYDROData_Obstacle.h>
#include <HYDROData_SplitToZonesTool.h>
createAction( SplitPolylinesId, "SPLIT_POLYLINES", "SPLIT_POLYLINES_ICO" );
createAction( MergePolylinesId, "MERGE_POLYLINES", "MERGE_POLYLINES_ICO" );
+ createAction( ShowAttrPolylinesId, "SHOWATTR_POLYLINES");
+
createAction( LandCoverScalarMapModeOnId, "LC_SCALARMAP_COLORING_ON" );
createAction( LandCoverScalarMapModeOffId, "LC_SCALARMAP_COLORING_OFF" );
case MergePolylinesId:
anOp = new HYDROGUI_MergePolylinesOp( aModule );
break;
+ case ShowAttrPolylinesId:
+ anOp = new HYDROGUI_ShowAttrPolyOp( aModule );
+ break;
case LandCoverScalarMapModeOnId:
case LandCoverScalarMapModeOffId:
anOp = new HYDROGUI_LandCoverColoringOp( aModule, theId );
SplitPolylinesId,
MergePolylinesId,
+ ShowAttrPolylinesId,
+
LandCoverScalarMapModeOnId,
LandCoverScalarMapModeOffId,
--- /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_PolyAttrDlg.h"
+#include <QVBoxLayout>
+#include <QPushButton>
+
+HYDROGUI_PolyAttrDlg::HYDROGUI_PolyAttrDlg( QWidget* theParent, const QStringList& theDBFData )
+ : QDialog( theParent )
+{
+ QVBoxLayout* aMainLayout = new QVBoxLayout( this );
+ aMainLayout->setMargin(5);
+ aMainLayout->setSpacing(5);
+ int nbcol = theDBFData.size()/2;
+ myDBFDataTable = new QTableWidget(1, nbcol);
+ //myDBFDataTable->setEditTriggers(QAbstractItemView:NoEditTriggers);
+
+ QStringList header;
+ for (int i = 0; i < nbcol; i++)
+ header << theDBFData[i];
+ myDBFDataTable->setHorizontalHeaderLabels(header);
+ myDBFDataTable->setShowGrid(true);
+
+ for (int i = theDBFData.size()/2; i < theDBFData.size(); i++)
+ {
+ QTableWidgetItem* item = new QTableWidgetItem(theDBFData[i]);
+ item->setFlags(item->flags() ^ Qt::ItemIsEditable);
+ myDBFDataTable->setItem(0, i-theDBFData.size()/2, item);
+ }
+
+ aMainLayout->addWidget(myDBFDataTable);
+
+ QPushButton* anOkButton = new QPushButton( tr("OK"), this );
+ anOkButton->setDefault( true );
+ aMainLayout->addWidget( anOkButton );
+
+ connect( anOkButton, SIGNAL( clicked() ), this, SLOT( reject() ) );
+
+ setLayout(aMainLayout);
+
+}
+
+HYDROGUI_PolyAttrDlg::~HYDROGUI_PolyAttrDlg()
+{
+}
+
+
--- /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_POLYATTRDLG_H
+#define HYDROGUI_POLYATTRDLG_H
+
+#include <QTableWidget>
+#include <QDialog>
+
+class HYDROGUI_PolyAttrDlg : public QDialog
+{
+ Q_OBJECT
+
+public:
+
+ HYDROGUI_PolyAttrDlg( QWidget* theParent, const QStringList& theDBFData );
+ virtual ~HYDROGUI_PolyAttrDlg();
+
+private:
+ QTableWidget* myDBFDataTable;
+
+};
+
+#endif
--- /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_ShowAttrPolyOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+
+#include <HYDROData_Object.h>
+#include <HYDROData_IPolyline.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <SUIT_Desktop.h>
+#include <HYDROGUI_Tool2.h>
+#include <HYDROGUI_PolyAttrDlg.h>
+#include <HYDROData_PolylineXY.h>
+#include <SUIT_MessageBox.h>
+
+HYDROGUI_ShowAttrPolyOp::HYDROGUI_ShowAttrPolyOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule ),
+ myPolyAttrDlg( 0 )
+{
+ setName( tr( "SHOWATTR_POLYLINE" ) );
+}
+
+HYDROGUI_ShowAttrPolyOp::~HYDROGUI_ShowAttrPolyOp()
+{
+}
+
+void HYDROGUI_ShowAttrPolyOp::startOperation()
+{
+ HYDROGUI_Operation::startOperation();
+
+ HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects(module());
+ Handle(HYDROData_PolylineXY) aPolyXY = Handle(HYDROData_PolylineXY)::DownCast(aSeq(1));
+ QStringList aDbflist;
+ if (aPolyXY->GetDBFInfo(aDbflist))
+ {
+ myPolyAttrDlg = new HYDROGUI_PolyAttrDlg( module()->getApp()->desktop(), aDbflist );
+ myPolyAttrDlg->setModal( true );
+ myPolyAttrDlg->setWindowTitle(getName());
+ myPolyAttrDlg->exec();
+ }
+ else
+ SUIT_MessageBox::information( module()->getApp()->desktop(), getName(), tr("SHOWATTR_POLY_NO_ATTR"));
+
+ HYDROGUI_Operation::abort();
+}
+
--- /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_SHOWATTRPOLYOP_H
+#define HYDROGUI_SHOWATTRPOLYOP_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <HYDROData_Entity.h>
+
+class HYDROGUI_PolyAttrDlg;
+
+class HYDROGUI_ShowAttrPolyOp : public HYDROGUI_Operation
+{
+ Q_OBJECT
+
+public:
+ HYDROGUI_ShowAttrPolyOp( HYDROGUI_Module* theModule );
+ virtual ~HYDROGUI_ShowAttrPolyOp();
+
+protected:
+ virtual void startOperation();
+
+private:
+
+ HYDROGUI_PolyAttrDlg* myPolyAttrDlg;
+};
+
+#endif
\ No newline at end of file
<source>DSK_MERGE_POLYLINES</source>
<translation>Merge polylines</translation>
</message>
+ <message>
+ <source>DSK_SHOWATTR_POLYLINES</source>
+ <translation>Show DBF attributes</translation>
+ </message>
<message>
<source>DSK_UNDO</source>
<translation>Undo</translation>
<source>MEN_MERGE_POLYLINES</source>
<translation>Merge polylines</translation>
</message>
+ <message>
+ <source>MEN_SHOWATTR_POLYLINES</source>
+ <translation>Show DBF attributes</translation>
+ </message>
<message>
<source>MEN_UNDO</source>
<translation>Undo</translation>
<source>STB_MERGE_POLYLINES</source>
<translation>Merge polylines</translation>
</message>
+ <message>
+ <source>STB_SHOWATTR_POLYLINES</source>
+ <translation>Show DBF attributes</translation>
+ </message>
<message>
<source>STB_UNDO</source>
<translation>Undo</translation>
<source>IMPORT_POLYLINE</source>
<translation>Import Polyline</translation>
</message>
+ <message>
+ <source>IMPORT_POLYLINE_USE_NAME_ATTR</source>
+ <translation>DBF file contains 'name' field. Would you like to use the value of this field as a name of polyline?</translation>
+ </message>
<message>
<source>POLYLINE_FILTER</source>
<translation>Shape files (*.shp)</translation>
</message>
</context>
+ <context>
+ <name>HYDROGUI_ShowAttrPolyOp</name>
+ <message>
+ <source>SHOWATTR_POLYLINE</source>
+ <translation>DBF attributes of polyline</translation>
+ </message>
+ <message>
+ <source>SHOWATTR_POLY_NO_ATTR</source>
+ <translation>This polyline does not contain DBF information</translation>
+ </message>
+ </context>
+
<context>
<name>HYDROGUI_SplitPolylinesDlg</name>
<message>