From: isn Date: Thu, 5 Nov 2015 11:31:22 +0000 (+0300) Subject: LCM // Import/Export of SHP p.7 X-Git-Tag: v1.5~58^2~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=acd7a6036bedb1360688f10a57f52a3daca3d84c;p=modules%2Fhydro.git LCM // Import/Export of SHP p.7 --- diff --git a/src/HYDROData/HYDROData_LandCoverMap.cxx b/src/HYDROData/HYDROData_LandCoverMap.cxx index e2ff679f..5487b6ad 100644 --- a/src/HYDROData/HYDROData_LandCoverMap.cxx +++ b/src/HYDROData/HYDROData_LandCoverMap.cxx @@ -264,6 +264,8 @@ void HYDROData_LandCoverMap::ExportDBF( const QString& theDBFFileName, const QStringList& theDBFValues, const QStringList& theStricklerTypes) const { + if (theDBFValues.size() != theStricklerTypes.size()) + return; HYDROData_ShapeFile anExporter; std::vector theAttrV; Iterator anIt( *this ); @@ -282,8 +284,8 @@ void HYDROData_LandCoverMap::ExportDBF( const QString& theDBFFileName, else aCurAttrV.myIsNull = true; } - - anExporter.DBF_WriteFieldAndValues(theDBFFileName, theFieldName, HYDROData_ShapeFile::DBF_FieldType_String, theAttrV, true); + //use actual str value; not the raw value + anExporter.DBF_WriteFieldAndValues(theDBFFileName, theFieldName, HYDROData_ShapeFile::DBF_FieldType_String, theAttrV, false); } diff --git a/src/HYDROData/HYDROData_ShapeFile.cxx b/src/HYDROData/HYDROData_ShapeFile.cxx index b8b3effd..629de51b 100644 --- a/src/HYDROData/HYDROData_ShapeFile.cxx +++ b/src/HYDROData/HYDROData_ShapeFile.cxx @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -47,6 +48,7 @@ #include #include #include +#include #ifdef WIN32 #pragma warning( disable: 4996 ) @@ -235,53 +237,88 @@ int HYDROData_ShapeFile::WriteObjectPolygon(SHPHandle theShpHandle, const TopoDS void HYDROData_ShapeFile::ProcessFace(TopoDS_Face theFace, SHPHandle theShpHandle) { + if (theFace.ShapeType() != TopAbs_FACE) + return; SHPObject *aSHPObj; std::vector x, y; std::vector anPartStart; - if (theFace.ShapeType() == TopAbs_FACE) + TopoDS_Wire OuterW = BRepTools::OuterWire(theFace); + NCollection_Sequence aWires; + + //write an outer wire first + aWires.Append(OuterW); + TopExp_Explorer Ex(theFace, TopAbs_WIRE); + for (; Ex.More(); Ex.Next()) { - TopExp_Explorer Ex(theFace, TopAbs_WIRE); - int NbWires = 0; - for (; Ex.More(); Ex.Next()) + TopoDS_Wire aW = TopoDS::Wire(Ex.Current()); + if (aW.IsEqual(OuterW)) + continue; + aWires.Append(aW); + } + + //TopExp_Explorer Ex(theFace, TopAbs_WIRE); + int NbWires = 0; + for (int k = 1; k <= aWires.Length(); k++) + { + TopoDS_Wire aW = aWires(k); + if (aW.IsNull()) + continue; + NbWires++; + // Try to reorder edges + Handle(ShapeFix_Wire) aSFW = new ShapeFix_Wire( aW, theFace, Precision::Confusion() ); + aSFW->FixReorder(); + Handle(ShapeExtend_WireData) aSEWD = aSFW->WireData(); + Standard_Integer nbE = aSEWD->NbEdges(); + // + anPartStart.push_back(x.size()); + NCollection_Sequence aPnts; + for (Standard_Integer i = 1; i <= nbE; i++) { - TopoDS_Wire aW = TopoDS::Wire(Ex.Current()); - if (aW.IsNull()) + TopoDS_Edge E = aSEWD->Edge(i); + TopoDS_Vertex aV = TopExp::LastVertex(E, 1); + if (aV.IsNull()) continue; - NbWires++; - anPartStart.push_back(x.size()); - TopExp_Explorer aVEx(aW, TopAbs_VERTEX); - NCollection_Sequence aPnts; - for (; aVEx.More(); aVEx.Next()) - { - TopoDS_Vertex aV = TopoDS::Vertex(aVEx.Current()); - if (aV.IsNull()) - continue; - gp_Pnt P = BRep_Tool::Pnt(aV); - aPnts.Append(gp_Pnt2d(P.X(), P.Y())); - } - NCollection_Sequence aNPnts; - aNPnts.Append(aPnts.First()); - for (int j = 1; j <= aPnts.Size() - 1; j++) - { - if (!aPnts(j).IsEqual(aPnts(j + 1), Precision::Confusion())) - aNPnts.Append(aPnts(j + 1)); - } + gp_Pnt P = BRep_Tool::Pnt(aV); + aPnts.Append(gp_Pnt2d(P.X(), P.Y())); + } + NCollection_Sequence aNPnts; + aNPnts.Append(aPnts.First()); + for (int j = 1; j <= aPnts.Size() - 1; j++) + { + if (!aPnts(j).IsEqual(aPnts(j + 1), Precision::Confusion())) + aNPnts.Append(aPnts(j + 1)); + } + if (k == 1) + { + //an outer wire + //clockwise direction for (int j = 1; j <= aNPnts.Size(); j++) { x.push_back( aNPnts(j).X()); y.push_back( aNPnts(j).Y()); } - //x.push_back( aNPnts(1).X()); - //y.push_back( aNPnts(1).Y()); + x.push_back( aNPnts(1).X()); + y.push_back( aNPnts(1).Y()); + } + else + { + //holes + //counter-clockwise direction + for (int j = aNPnts.Size(); j > 0; j--) + { + x.push_back( aNPnts(j).X()); + y.push_back( aNPnts(j).Y()); + } + x.push_back( aNPnts(aNPnts.Size()).X()); + y.push_back( aNPnts(aNPnts.Size()).Y()); } - - aSHPObj = SHPCreateObject( SHPT_POLYGON, -1, NbWires, &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL ); - SHPWriteObject( theShpHandle, -1, aSHPObj ); - SHPDestroyObject( aSHPObj ); } - else - return; + + aSHPObj = SHPCreateObject( SHPT_POLYGON, -1, NbWires, &anPartStart[0], NULL, x.size(), &x[0], &y[0], NULL, NULL ); + SHPWriteObject( theShpHandle, -1, aSHPObj ); + SHPDestroyObject( aSHPObj ); + } bool HYDROData_ShapeFile::Parse(SHPHandle theHandle, ShapeType theType, int& theShapeTypeOfFile) diff --git a/src/HYDROGUI/CMakeLists.txt b/src/HYDROGUI/CMakeLists.txt index 6c670c1d..061a7632 100644 --- a/src/HYDROGUI/CMakeLists.txt +++ b/src/HYDROGUI/CMakeLists.txt @@ -42,6 +42,7 @@ set(PROJECT_HEADERS HYDROGUI_ImportSinusXOp.h HYDROGUI_ExportSinusXOp.h HYDROGUI_ExportSinusXDlg.h + HYDROGUI_ExportLandCoverMapDlg.h HYDROGUI_InputPanel.h HYDROGUI_LandCoverMapDlg.h HYDROGUI_LandCoverMapOp.h @@ -175,12 +176,13 @@ set(PROJECT_SOURCES HYDROGUI_ImportBathymetryOp.cxx HYDROGUI_ImportImageDlg.cxx HYDROGUI_ImportImageOp.cxx - HYDROGUI_ImportLandCoverMapOp.cxx - HYDROGUI_ImportLandCoverMapDlg.cxx + HYDROGUI_ImportLandCoverMapOp.cxx + HYDROGUI_ImportLandCoverMapDlg.cxx HYDROGUI_ImportPolylineOp.cxx HYDROGUI_ImportSinusXOp.cxx HYDROGUI_ExportSinusXOp.cxx HYDROGUI_ExportSinusXDlg.cxx + HYDROGUI_ExportLandCoverMapDlg.cxx HYDROGUI_InputPanel.cxx HYDROGUI_LandCoverMapDlg.cxx HYDROGUI_LandCoverMapOp.cxx diff --git a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx index 72915e5d..9baba92b 100644 --- a/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ExportFileOp.cxx @@ -22,12 +22,15 @@ #include "HYDROGUI_Module.h" #include "HYDROGUI_UpdateFlags.h" #include "HYDROGUI_Tool.h" +#include "HYDROGUI_ExportLandCoverMapDlg.h" #include #include #include #include #include +#include + #include #include @@ -50,6 +53,12 @@ #include #include #include +#include +#include +#include + +#include +#include HYDROGUI_ExportFileOp::HYDROGUI_ExportFileOp( HYDROGUI_Module* theModule ) : HYDROGUI_Operation( theModule ) @@ -104,9 +113,74 @@ void HYDROGUI_ExportFileOp::startOperation() else { //Export polygons - //aSeq.Size() <= 1 - Handle_HYDROData_LandCoverMap aLCM = Handle(HYDROData_LandCoverMap)::DownCast( aSeq(1) ); - anExporter.Export(aFileName, aLCM, aNonExpList); + //Extract all attribute names from all strickler tables + Handle_HYDROData_Document aDoc = HYDROData_Document::Document( application()->activeStudy()->id() ); + QSet AttrNames; + //use QSet to store attribute names. Yet it's not so good if the document contains two strickler types + //with the same name + if ( aDoc ) + { + HYDROData_Iterator It( aDoc, KIND_STRICKLER_TABLE ); + for( ; It.More(); It.Next() ) + { + Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( It.Current() ); + if ( !aStricklerTableObj.IsNull()) + AttrNames << aStricklerTableObj->GetAttrName(); + } + } + else + return; + + // + HYDROGUI_ExportLandCoverMapDlg aDlg( module()->getApp()->desktop(), AttrNames.toList()); + if ( aDlg.exec() == HYDROGUI_ExportLandCoverMapDlg::Accepted ) + { + //In our case : aSeq.Size() == 1 + //Export of multiple landcover maps into the one shp-file is disallowed. + Handle_HYDROData_LandCoverMap aLCM = Handle(HYDROData_LandCoverMap)::DownCast( aSeq(1) ); + QString CItem = aDlg.getCurrentItem(); + Handle(HYDROData_StricklerTable) StricklerTableObj; + { + HYDROData_Iterator It( aDoc, KIND_STRICKLER_TABLE ); + for( ; It.More(); It.Next() ) + { + StricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( It.Current() ); + if ( !StricklerTableObj.IsNull() && StricklerTableObj->GetAttrName() == CItem) + break; + } + } + + //export shape-data + anExporter.Export(aFileName, aLCM, aNonExpList); + QString DBFFileName = aFileName.replace( ".shp", ".dbf", Qt::CaseInsensitive); + //Even if attribute-checkbox is unchecked, the .dbf-file should be removed. + //otherwise it may be used with wrong .shp-file. This is an incorrect behaivor. + remove (DBFFileName.toStdString().c_str()); + bool ToSaveAttrInfo = aDlg.getAttrCheckBoxState(); + if (ToSaveAttrInfo) + { + //export attribute info + QStringList AttrValues; + QStringList StricklerTypes; + if (aNonExpList.empty()) + { + HYDROData_LandCoverMap::Iterator It( aLCM ); + for( ; It.More(); It.Next() ) + { + QString ST = It.StricklerType(); + AttrValues << StricklerTableObj->GetAttrValue(ST); + StricklerTypes << ST; + } + } + aLCM->ExportDBF(DBFFileName, CItem, AttrValues, StricklerTypes); + } + } + else + { + abort(); + return; + } + } if (!aNonExpList.empty()) diff --git a/src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.cxx b/src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.cxx new file mode 100644 index 00000000..71063efc --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.cxx @@ -0,0 +1,72 @@ +// 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_ExportLandCoverMapDlg.h" + +#include + +#include +#include +#include + +HYDROGUI_ExportLandCoverMapDlg::HYDROGUI_ExportLandCoverMapDlg( QWidget* theParent, const QStringList& AttrItems ) + : QtxDialog( theParent, false, true, QtxDialog::OKCancel ) +{ + setWindowTitle( tr( "EXPORT_LANDCOVERMAP" ) ); + setButtonPosition( Left, OK ); + setButtonPosition( Right, Cancel ); + + myAttrCheckBox = new QCheckBox( tr( "Write Strickler Types as attributes values to DBF file" ), mainFrame() ); + myAttrCheckBox->setChecked(false); + myAvFields = new QComboBox( mainFrame() ); + myAvFields->setEnabled(false); + myAvFields->addItems( AttrItems ); + + QGridLayout* aLayout = new QGridLayout( mainFrame() ); + aLayout->setMargin( 5 ); + aLayout->setSpacing( 5 ); + aLayout->addWidget( myAttrCheckBox, 0, 0 ); + aLayout->addWidget( myAvFields, 1, 0, 1, 2 ); + + setMinimumSize( 300, 100 ); + + connect( myAttrCheckBox, SIGNAL(clicked(bool)), this, SLOT(onAttrCBChecked(bool))); + +} + +HYDROGUI_ExportLandCoverMapDlg::~HYDROGUI_ExportLandCoverMapDlg() +{ +} + +void HYDROGUI_ExportLandCoverMapDlg::onAttrCBChecked( bool theState ) +{ + if (theState) + myAvFields->setEnabled(true); + else + myAvFields->setEnabled(false); +} + +QString HYDROGUI_ExportLandCoverMapDlg::getCurrentItem() const +{ + return myAvFields->currentText(); +} + +bool HYDROGUI_ExportLandCoverMapDlg::getAttrCheckBoxState() +{ + return myAttrCheckBox->isChecked(); +} diff --git a/src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.h b/src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.h new file mode 100644 index 00000000..a4b5bdcb --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.h @@ -0,0 +1,48 @@ +// 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_ExportLandCoverMapDlg_H +#define HYDROGUI_ExportLandCoverMapDlg_H + +#include + +class QCheckBox; +class QComboBox; + +class HYDROGUI_ExportLandCoverMapDlg : public QtxDialog +{ + Q_OBJECT + +public: + HYDROGUI_ExportLandCoverMapDlg( QWidget* = 0, const QStringList& AttrItems = QStringList()); + virtual ~HYDROGUI_ExportLandCoverMapDlg(); + +protected slots: + void onAttrCBChecked(bool theState); + +public: + QString getCurrentItem() const; + bool getAttrCheckBoxState(); + +private: + QCheckBox* myAttrCheckBox; + QComboBox* myAvFields; +}; + +#endif diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx index 7fd79557..e2032638 100644 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx @@ -265,10 +265,11 @@ QString HYDROGUI_ImportLandCoverMapDlg::getFileName() const void HYDROGUI_ImportLandCoverMapDlg::FillCorrTable(const QStringList& theFirstColumn, const QStringList& theSecondColumn, + const QVector theDefCBIndices, const QVector theColors) { - int FCSize = theFirstColumn.size(); - int SCSize = theSecondColumn.size(); + int FCSize = theFirstColumn.size(); // == theDefCBIndices.size() ! + int SCSize = theSecondColumn.size(); myStrColors = theColors; @@ -280,6 +281,7 @@ void HYDROGUI_ImportLandCoverMapDlg::FillCorrTable(const QStringList& theFirstCo myTableW->setHorizontalHeaderItem(0, Header_1); myTableW->setHorizontalHeaderItem(1, Header_2); myTableW->setHorizontalHeaderItem(2, Header_3); + myTableW->horizontalHeader()->setResizeMode(QHeaderView::ResizeMode::ResizeToContents); // for (int i = 0; i < FCSize; i++) { @@ -296,15 +298,17 @@ void HYDROGUI_ImportLandCoverMapDlg::FillCorrTable(const QStringList& theFirstCo connect(aCB, SIGNAL(currentIndexChanged(int)), signalMap, SLOT(map())); signalMap->setMapping(aCB, i); aCB->addItems(theSecondColumn); + aCB->setCurrentIndex(theDefCBIndices[i]); myTableW->setCellWidget(i, 1, aCB); } connect(signalMap, SIGNAL(mapped(int)), this, SLOT(OnComboBoxColorChanged(int))); + // for (int i = 0; i < FCSize; i++) { myTableW->setItem(i, 2, new QTableWidgetItem); //take the first color from array; this color corresponds to the first item in the combo box - myTableW->item(i, 2)->setBackground(myStrColors[0]); + myTableW->item(i, 2)->setBackground(myStrColors[theDefCBIndices[i]]); } } @@ -347,7 +351,10 @@ bool HYDROGUI_ImportLandCoverMapDlg::acceptCurrent() const case 1: { if (myDBFAttr->selectedItems().empty()) + { + SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), "Attribute isn't selected"); return false; + } break; } default: diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h index 22c3dea3..ac5503f9 100644 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h @@ -47,6 +47,7 @@ public: void setAttributeNames( const QStringList& theAttrNames ); void FillCorrTable(const QStringList& theFirstColumn, const QStringList& theSecondColumn, + const QVector theDefCBIndices, const QVector theColors); QStringList getSelectedPolygonNames() const; diff --git a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx index 45f345fb..6274879f 100644 --- a/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx @@ -28,48 +28,43 @@ #include "HYDROGUI_Tool.h" #include "HYDROGUI_ImportLandCoverMapDlg.h" #include "HYDROGUI_Shape.h" -#include #include - #include #include #include #include +#include +#include #include #include -#include - -#include -#include -#include #include +#include +#include #include #include #include - #include #include #include #include -#include - -#include -#include #include #include #include #include + #include +#include +#include -#include +#include + +#define MAX_LCM_NAME_INDEX 1000 //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 ) { @@ -247,7 +242,7 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags, 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; @@ -268,7 +263,7 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags, aST = aSTL.at(StricklerTypesInd); } // else => ST is empty - aMapFace2ST.Add( TopoDS::Face( aShape ), aST ); //TODO get from tableW + aMapFace2ST.Add( TopoDS::Face( aShape ), aST ); } // @@ -277,10 +272,25 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags, QString ObjName; if ( !aPanel->getFileName().isEmpty() ) ObjName = aPanel->getObjectName(); + + Handle_HYDROData_Document aDoc = HYDROData_Document::Document( application()->activeStudy()->id() ); + + //check if name of LCM is already exists + QSet aNameList; + if (aDoc) + { + HYDROData_Iterator It( aDoc, KIND_LAND_COVER_MAP ); + for( ; It.More(); It.Next() ) + aNameList << It.Current()->GetName(); + } + + QString NewName = ObjName; + for ( int i = 1; i < MAX_LCM_NAME_INDEX && aNameList.contains(NewName); i++) + NewName = ObjName + "_" + QString::number(i); if( !myLCM.IsNull() ) { - myLCM->SetName( ObjName ); + myLCM->SetName( NewName ); myLCM->SetColor( Qt::gray ); myLCM->Show(); module()->setIsToUpdate( myLCM ); @@ -362,9 +372,8 @@ void HYDROGUI_ImportLandCoverMapOp::erasePreview() void HYDROGUI_ImportLandCoverMapOp::abortOperation() { LightApp_Application* anApp = module()->getApp(); - if ( anApp ) { + if ( anApp ) anApp->disconnect( this ); - } erasePreview(); myImporter.Free(); @@ -397,21 +406,20 @@ void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex ) //Collect all strickler_types QSet aSTSet; Handle_HYDROData_Document aDoc = HYDROData_Document::Document( application()->activeStudy()->id() ); + Handle(HYDROData_StricklerTable) DefStricklerTableObj; if ( aDoc ) { HYDROData_Iterator It( aDoc, KIND_STRICKLER_TABLE ); for( ; It.More(); It.Next() ) { Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( It.Current() ); - QString TT = aStricklerTableObj->GetAttrName(); + if (DefStricklerTableObj.IsNull()) + DefStricklerTableObj = aStricklerTableObj; if ( !aStricklerTableObj.IsNull()) { const QStringList& aStricklerList = aStricklerTableObj->GetTypes(); foreach (QString aStr, aStricklerList) - { - QString AttVal = aStricklerTableObj->GetAttrValue(aStr); aSTSet << aStr; - } } } } @@ -425,7 +433,28 @@ void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex ) STColors.append (col); } - aPanel->FillCorrTable(SetOfAttrValuesList, aSTSetList, STColors); + //add an empty Strickler type + aSTSetList.prepend(""); + STColors.prepend(QColor(Qt::gray)); + + QVector aCurCBIndices(SetOfAttrValuesList.size()); + if (DefStricklerTableObj->GetAttrName() == aPanel->getSelectedFieldName()) + { + for (int i = 0; i < SetOfAttrValuesList.size(); i++) + { + QString ST = DefStricklerTableObj->GetType(SetOfAttrValuesList[i]); + int IndofSt = aSTSetList.indexOf(ST); + aCurCBIndices[i] = IndofSt; + } + } + else + { + //TODO add warning ??? + for (int i = 0; i < SetOfAttrValuesList.size(); i++) + aCurCBIndices[i] = 0; + } + + aPanel->FillCorrTable(SetOfAttrValuesList, aSTSetList, aCurCBIndices, STColors); } }