]> SALOME platform Git repositories - modules/hydro.git/commitdiff
Salome HOME
LCM // Import/Export of SHP p.8
authorisn <isn@opencascade.com>
Mon, 9 Nov 2015 09:27:28 +0000 (12:27 +0300)
committerisn <isn@opencascade.com>
Mon, 9 Nov 2015 13:43:19 +0000 (16:43 +0300)
src/HYDROGUI/HYDROGUI_ExportFileOp.cxx
src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.cxx
src/HYDROGUI/HYDROGUI_ExportLandCoverMapDlg.h
src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.cxx
src/HYDROGUI/HYDROGUI_ImportLandCoverMapDlg.h
src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.cxx
src/HYDROGUI/HYDROGUI_ImportLandCoverMapOp.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts

index 9baba92b180b6dd1195a3352ae807b0985c61d7c..02f6b2dfe057f6fd049ce4c20a04d697e6c98514 100644 (file)
@@ -115,64 +115,64 @@ void HYDROGUI_ExportFileOp::startOperation()
         //Export polygons
         //Extract all attribute names from all strickler tables
         Handle_HYDROData_Document aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
-        QSet<QString> AttrNames;
+        QSet<QString> anAttrNames;
         //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 )
+        if (aDoc)
         {
-          HYDROData_Iterator It( aDoc, KIND_STRICKLER_TABLE );
-          for( ; It.More(); It.Next() )
+          HYDROData_Iterator anIt( aDoc, KIND_STRICKLER_TABLE );
+          for( ; anIt.More(); anIt.Next() )
           {
-            Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( It.Current() );
+            Handle(HYDROData_StricklerTable) aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
             if ( !aStricklerTableObj.IsNull())
-              AttrNames << aStricklerTableObj->GetAttrName();
+              anAttrNames << aStricklerTableObj->GetAttrName();
           }
         }
         else
           return; 
 
         //
-        HYDROGUI_ExportLandCoverMapDlg aDlg( module()->getApp()->desktop(), AttrNames.toList());
+        HYDROGUI_ExportLandCoverMapDlg aDlg( module()->getApp()->desktop(), anAttrNames.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;
+          QString aCItem = aDlg.getCurrentItem();
+          Handle(HYDROData_StricklerTable) aStricklerTableObj;
           {
-            HYDROData_Iterator It( aDoc, KIND_STRICKLER_TABLE );
-            for( ; It.More(); It.Next() )
+            HYDROData_Iterator anIt( aDoc, KIND_STRICKLER_TABLE );
+            for( ; anIt.More(); anIt.Next() )
             {
-              StricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( It.Current() );
-              if ( !StricklerTableObj.IsNull() && StricklerTableObj->GetAttrName() == CItem)
+              aStricklerTableObj = Handle(HYDROData_StricklerTable)::DownCast( anIt.Current() );
+              if ( !aStricklerTableObj.IsNull() && aStricklerTableObj->GetAttrName() == aCItem)
                 break;
             }
           }
 
           //export shape-data
           anExporter.Export(aFileName, aLCM, aNonExpList);
-          QString DBFFileName = aFileName.replace( ".shp", ".dbf", Qt::CaseInsensitive);
+          QString aDBFFileName = 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)
+          remove (aDBFFileName.toStdString().c_str());
+          bool bToSaveAttrInfo = aDlg.getAttrCheckBoxState();
+          if (bToSaveAttrInfo)
           {
             //export attribute info
-            QStringList AttrValues;
-            QStringList StricklerTypes;
+            QStringList anAttrValues;
+            QStringList aStricklerTypes;
             if (aNonExpList.empty())
             {
-              HYDROData_LandCoverMap::Iterator It( aLCM );
-              for( ; It.More(); It.Next() )
+              HYDROData_LandCoverMap::Iterator aLCMIt( aLCM );
+              for( ; aLCMIt.More(); aLCMIt.Next() )
               {
-                QString ST = It.StricklerType();
-                AttrValues << StricklerTableObj->GetAttrValue(ST);
-                StricklerTypes << ST;
+                QString aST = aLCMIt.StricklerType();
+                anAttrValues << aStricklerTableObj->GetAttrValue(aST);
+                aStricklerTypes << aST;
               }
             }
-            aLCM->ExportDBF(DBFFileName, CItem, AttrValues, StricklerTypes);
+            aLCM->ExportDBF(aDBFFileName, aCItem, anAttrValues, aStricklerTypes);
           }
         }
         else
index 71063efc4fac1b2d02b8fc883ac5475407215f46..9da8db3674602c94459d2b946aef82c704690fec 100644 (file)
 #include <QVBoxLayout>
 #include <QComboBox>
 
-HYDROGUI_ExportLandCoverMapDlg::HYDROGUI_ExportLandCoverMapDlg( QWidget* theParent, const QStringList& AttrItems )
+HYDROGUI_ExportLandCoverMapDlg::HYDROGUI_ExportLandCoverMapDlg( QWidget* theParent, const QStringList& theAttrItems )
   : 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 = new QCheckBox( tr( "WRITE_ST_AS_ATTRS_TO_DBF" ), mainFrame() );
   myAttrCheckBox->setChecked(false);
   myAvFields = new QComboBox( mainFrame() );
   myAvFields->setEnabled(false);
-  myAvFields->addItems( AttrItems );
+  myAvFields->addItems( theAttrItems );
 
   QGridLayout* aLayout = new QGridLayout( mainFrame() );
   aLayout->setMargin( 5 );
index a4b5bdcb4f7f0c83e04321b885cbe3822f835baa..eda646f58bac964a455eb84fe994275394da957a 100644 (file)
@@ -30,7 +30,7 @@ class HYDROGUI_ExportLandCoverMapDlg : public QtxDialog
   Q_OBJECT
 
 public:
-  HYDROGUI_ExportLandCoverMapDlg( QWidget* = 0, const QStringList& AttrItems = QStringList());
+  HYDROGUI_ExportLandCoverMapDlg( QWidget* theParent = 0, const QStringList& theAttrItems = QStringList());
   virtual ~HYDROGUI_ExportLandCoverMapDlg();
 
 protected slots:
index e203263883d114959bcdbc3aed3cee9cb1cd66ef..bebfe82eec5f2ec43b9530df8f48d3273be759a8 100644 (file)
@@ -84,18 +84,18 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
   aLandcoverNameLayout->addWidget( myObjectName );
 
   QGroupBox* aPolygonsGroup = new QGroupBox( tr( "FOUNDED_POLYGONS" ) );
-  myPolygons = new QListWidget( aPolygonsGroup );
-  myPolygons->setSelectionMode( QListWidget::ExtendedSelection );
-  myPolygons->setEditTriggers( QListWidget::NoEditTriggers );
-  myPolygons->setViewMode( QListWidget::ListMode );
-  myPolygons->setSortingEnabled( false );
+  myPolygonsListWidget = new QListWidget( aPolygonsGroup );
+  myPolygonsListWidget->setSelectionMode( QListWidget::ExtendedSelection );
+  myPolygonsListWidget->setEditTriggers( QListWidget::NoEditTriggers );
+  myPolygonsListWidget->setViewMode( QListWidget::ListMode );
+  myPolygonsListWidget->setSortingEnabled( false );
 
   QBoxLayout* aPolygonsLayout = new QVBoxLayout;
-  aPolygonsLayout->addWidget( myPolygons );
+  aPolygonsLayout->addWidget( myPolygonsListWidget );
   aPolygonsGroup->setLayout( aPolygonsLayout );
 
   QVBoxLayout* aPageLayout = new QVBoxLayout;
-  myAttrCheckBox = new QCheckBox( "Use dBase attributes as a Strickler Types" ); //TODO replace with tr()
+  myAttrCheckBox = new QCheckBox( tr("USE_DBF_AS_ST") ); //TODO replace with tr()
   myAttrCheckBox->setChecked(true);
 
   // Layout
@@ -108,7 +108,7 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage1() {
   aPage->setLayout( aPageLayout );
 
   // Conections
-  connect( myPolygons, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
+  connect( myPolygonsListWidget, SIGNAL( itemSelectionChanged() ), this, SLOT( onItemSelectionChanged() ) );
   connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) ); 
   connect( myAttrCheckBox, SIGNAL(clicked(bool)), this, SLOT(onAttrCBChecked(bool)));
 
@@ -120,20 +120,20 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage2() {
   QFrame* aFrame = new QFrame( aPage );
 
   myAvAttrLabel = new QLabel();
-  myAvAttrLabel->setText("Available attributes");
+  myAvAttrLabel->setText(tr("AV_ATTRS"));
   
-  myDBFAttr = new QListWidget( );
-  myDBFAttr->setSelectionMode( QListWidget::SingleSelection );
-  myDBFAttr->setEditTriggers( QListWidget::NoEditTriggers );
-  myDBFAttr->setViewMode( QListWidget::ListMode );
-  myDBFAttr->setSortingEnabled( false );
+  myDBFAttrListWidget = new QListWidget( );
+  myDBFAttrListWidget->setSelectionMode( QListWidget::SingleSelection );
+  myDBFAttrListWidget->setEditTriggers( QListWidget::NoEditTriggers );
+  myDBFAttrListWidget->setViewMode( QListWidget::ListMode );
+  myDBFAttrListWidget->setSortingEnabled( false );
 
   // Layout
   QVBoxLayout* aPageLayout = new QVBoxLayout;
   aPageLayout->setMargin( 5 );
   aPageLayout->setSpacing( 5 );
   aPageLayout->addWidget( myAvAttrLabel );
-  aPageLayout->addWidget( myDBFAttr );
+  aPageLayout->addWidget( myDBFAttrListWidget );
   aPage->setLayout( aPageLayout );
 
   return aPage;
@@ -143,17 +143,17 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage3() {
 
   QWizardPage* aPage = new QWizardPage( mainFrame() );
   QFrame* aFrame = new QFrame( aPage );
-  myCLabel = new QLabel();
-  myCLabel->setText("Correspondence");
+  myCorrLabel = new QLabel();
+  myCorrLabel->setText(tr ("CORR"));
   
-  myTableW = new QTableWidget();
+  myCorrTableWidget = new QTableWidget();
 
   // Layout
   QVBoxLayout* aPageLayout = new QVBoxLayout;
   aPageLayout->setMargin( 5 );
   aPageLayout->setSpacing( 5 );
-  aPageLayout->addWidget( myCLabel );
-  aPageLayout->addWidget( myTableW );
+  aPageLayout->addWidget( myCorrLabel );
+  aPageLayout->addWidget( myCorrTableWidget );
   aPage->setLayout( aPageLayout );
   return aPage;
 }
@@ -161,47 +161,34 @@ QWizardPage* HYDROGUI_ImportLandCoverMapDlg::createPage3() {
 
 HYDROGUI_ImportLandCoverMapDlg::~HYDROGUI_ImportLandCoverMapDlg()
 {
-  myPolygons->clear();
-  myDBFAttr->clear();
+  myPolygonsListWidget->clear();
+  myDBFAttrListWidget->clear();
 }
 
 void HYDROGUI_ImportLandCoverMapDlg::reset()
 {
-  myPolygons->clear();
-  myDBFAttr->clear();
+  myPolygonsListWidget->clear();
+  myDBFAttrListWidget->clear();
 }
 
 void HYDROGUI_ImportLandCoverMapDlg::setPolygonNames( const QStringList& theNames )
 {
-  myPolygons->clear();
-  myPolygons->addItems( theNames );
+  myPolygonsListWidget->clear();
+  myPolygonsListWidget->addItems( theNames );
 }
 
 void HYDROGUI_ImportLandCoverMapDlg::setAttributeNames( const QStringList& theAttrNames )
 {
-  myDBFAttr->clear();
-  myDBFAttr->addItems( theAttrNames );
+  myDBFAttrListWidget->clear();
+  myDBFAttrListWidget->addItems( theAttrNames );
 }
 
-/*void HYDROGUI_ImportLandCoverMapDlg::removePolygonNames( const QStringList& theNames )
-{
-  QList<QListWidgetItem*> aFoundItems;
-
-  foreach ( const QString& aName, theNames ) {
-    aFoundItems = myPolygons->findItems( aName, Qt::MatchExactly );
-    foreach ( QListWidgetItem* anItem, aFoundItems ) {
-      anItem = myPolygons->takeItem( myPolygons->row( anItem ) );
-      delete anItem;
-    }
-  }
-}*/
-
 void HYDROGUI_ImportLandCoverMapDlg::setSelectedPolygonNames( const QStringList& theNames )
 {
-  myPolygons->clearSelection();
+  myPolygonsListWidget->clearSelection();
 
   foreach( const QString aName, theNames ) {
-    QList<QListWidgetItem*> anItems = myPolygons->findItems( aName, Qt::MatchExactly );
+    QList<QListWidgetItem*> anItems = myPolygonsListWidget->findItems( aName, Qt::MatchExactly );
     if ( anItems.count() == 1 ) {
       anItems.first()->setSelected( true );
     }
@@ -217,15 +204,13 @@ QStringList HYDROGUI_ImportLandCoverMapDlg::getSelectedPolygonNames() const
 {
   QStringList aSelectedNames;
 
-  QList<QListWidgetItem*> aSelectedItems = myPolygons->selectedItems();
+  QList<QListWidgetItem*> aSelectedItems = myPolygonsListWidget->selectedItems();
   foreach( const QListWidgetItem* anItem, aSelectedItems )
     aSelectedNames << anItem->text();
 
   return aSelectedNames;
 }
 
-
-
 void HYDROGUI_ImportLandCoverMapDlg::onBrowse()
 {
   QString aFilter( tr( "LANDCOVERMAP_FILTER" ) );
@@ -263,94 +248,94 @@ QString HYDROGUI_ImportLandCoverMapDlg::getFileName() const
 }
 
 
-void HYDROGUI_ImportLandCoverMapDlg::FillCorrTable(const QStringList& theFirstColumn, 
+void HYDROGUI_ImportLandCoverMapDlg::FillCorrespondenceTable(const QStringList& theFirstColumn, 
                                                    const QStringList& theSecondColumn,
                                                    const QVector<int> theDefCBIndices,
                                                    const QVector<QColor> theColors)
 {
-  int FCSize = theFirstColumn.size();  // == theDefCBIndices.size() !
-  int SCSize = theSecondColumn.size(); 
+  int aFCSize = theFirstColumn.size();  // == theDefCBIndices.size() !
+  int aSCSize = theSecondColumn.size(); 
 
   myStrColors = theColors;
 
-  myTableW->setRowCount(FCSize);
-  myTableW->setColumnCount(3);
-  QTableWidgetItem* Header_1 = new QTableWidgetItem(QString("Attribute"), QTableWidgetItem::Type);
-  QTableWidgetItem* Header_2 = new QTableWidgetItem(QString("Strickler Type"), QTableWidgetItem::Type);
-  QTableWidgetItem* Header_3 = new QTableWidgetItem(QString("Color"), QTableWidgetItem::Type);
-  myTableW->setHorizontalHeaderItem(0, Header_1);
-  myTableW->setHorizontalHeaderItem(1, Header_2);
-  myTableW->setHorizontalHeaderItem(2, Header_3);
-  myTableW->horizontalHeader()->setResizeMode(QHeaderView::ResizeMode::ResizeToContents);
+  myCorrTableWidget->setRowCount(aFCSize);
+  myCorrTableWidget->setColumnCount(3);
+  QTableWidgetItem* aHeader_1 = new QTableWidgetItem(QString(tr("TABLE_H1")), QTableWidgetItem::Type);
+  QTableWidgetItem* aHeader_2 = new QTableWidgetItem(QString(tr("TABLE_H2")), QTableWidgetItem::Type);
+  QTableWidgetItem* aHeader_3 = new QTableWidgetItem(QString(tr("TABLE_H3")), QTableWidgetItem::Type);
+  myCorrTableWidget->setHorizontalHeaderItem(0, aHeader_1);
+  myCorrTableWidget->setHorizontalHeaderItem(1, aHeader_2);
+  myCorrTableWidget->setHorizontalHeaderItem(2, aHeader_3);
+  myCorrTableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeMode::ResizeToContents);
   //
-  for (int i = 0; i < FCSize; i++)
+  for (int i = 0; i < aFCSize; i++)
   {
     QTableWidgetItem* aTWI = new QTableWidgetItem();
     aTWI->setText(theFirstColumn.at(i));
     aTWI->setFlags(Qt::ItemIsUserCheckable);
-    myTableW->setItem(i, 0, aTWI);
+    myCorrTableWidget->setItem(i, 0, aTWI);
   }
   //
   QSignalMapper* signalMap = new QSignalMapper();
-  for (int i = 0; i < FCSize; i++)
+  for (int i = 0; i < aFCSize; i++)
   {
     QComboBox* aCB = new QComboBox();
     connect(aCB, SIGNAL(currentIndexChanged(int)), signalMap, SLOT(map()));
     signalMap->setMapping(aCB, i);
     aCB->addItems(theSecondColumn);
     aCB->setCurrentIndex(theDefCBIndices[i]);
-    myTableW->setCellWidget(i, 1, aCB);
+    myCorrTableWidget->setCellWidget(i, 1, aCB);
   }
-  connect(signalMap, SIGNAL(mapped(int)), this, SLOT(OnComboBoxColorChanged(int)));
+  connect(signalMap, SIGNAL(mapped(int)), this, SLOT(onComboBoxColorChanged(int)));
 
   //
-  for (int i = 0; i < FCSize; i++)
+  for (int i = 0; i < aFCSize; i++)
   {
-    myTableW->setItem(i, 2, new QTableWidgetItem);
+    myCorrTableWidget->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[theDefCBIndices[i]]);
+    myCorrTableWidget->item(i, 2)->setBackground(myStrColors[theDefCBIndices[i]]);
   }
 
 }
 
 QString HYDROGUI_ImportLandCoverMapDlg::getSelectedFieldName() const
 {
-  return myDBFAttr->selectedItems().first()->text();
+  return myDBFAttrListWidget->selectedItems().first()->text();
 }
 
-void HYDROGUI_ImportLandCoverMapDlg::setFirstPageState(bool bState)
+void HYDROGUI_ImportLandCoverMapDlg::setFirstPageState(bool theState)
 {
-  myFirstPageState = bState;
+  myFirstPageState = theState;
 }
 
 bool HYDROGUI_ImportLandCoverMapDlg::acceptCurrent() const
 {
   //Check the state of the current page
-  int CurrPage = wizard()->currentIndex();
-  switch ( CurrPage )
+  int aCurrPage = wizard()->currentIndex();
+  switch ( aCurrPage )
   {
     case 0:
     {
       if (!myFirstPageState)
       {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), "File isn't chosen");
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("FILE_ISNT_CHOSEN"));
         return false;
       }
-      if (myPolygons->selectedItems().empty())
+      if (myPolygonsListWidget->selectedItems().empty())
       {
-        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), "Polygons isn't selected");
+        SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), tr("POLYGONS_ISNT_SELECTED"));
         return false;
       }
       if (getAttrCheckBoxState() && !getDbfState())
       {
-         SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "DBF_LOAD_ERROR" ), "Cant open DBF file or it's corrupted");
+         SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "DBF_LOAD_ERROR" ), tr("DBF_LOAD_ERR_MESS"));
          return false;
       }
       break;
     }
     case 1:
     {
-      if (myDBFAttr->selectedItems().empty())
+      if (myDBFAttrListWidget->selectedItems().empty())
       {
         SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "LCM_IMPORT_WARNING" ), "Attribute isn't selected");
         return false;
@@ -363,20 +348,20 @@ bool HYDROGUI_ImportLandCoverMapDlg::acceptCurrent() const
   return true;
 }
 
-void HYDROGUI_ImportLandCoverMapDlg::GetAttribute2StricklerCorr(QStringList& AttrValues, QStringList& ST)
+void HYDROGUI_ImportLandCoverMapDlg::getValAttr2StricklerTypeCorr(QStringList& theAttrValues, QStringList& theST)
 {
-  int aRowCount = myTableW->rowCount();
+  int aRowCount = myCorrTableWidget->rowCount();
   for (int i = 0; i < aRowCount; i++)
   {
-    QTableWidgetItem* aTWI = myTableW->item(i, 0);
-    AttrValues.push_back(aTWI->text());
+    QTableWidgetItem* aTWI = myCorrTableWidget->item(i, 0);
+    theAttrValues.push_back(aTWI->text());
   }
 
   for (int i = 0; i < aRowCount; i++)
   {
-    QWidget* aW = myTableW->cellWidget(i, 1);
+    QWidget* aW = myCorrTableWidget->cellWidget(i, 1);
     QComboBox* aCB = dynamic_cast<QComboBox*> (aW);
-    ST.push_back(aCB->currentText());
+    theST.push_back(aCB->currentText());
   }
 }
 
@@ -385,7 +370,7 @@ QVector<int> HYDROGUI_ImportLandCoverMapDlg::getSelectedPolygonIndices() const
 {
   QVector<int> aSelectedIndices;
 
-  QModelIndexList aSelectedItems = myPolygons->selectionModel()->selectedIndexes();
+  QModelIndexList aSelectedItems = myPolygonsListWidget->selectionModel()->selectedIndexes();
   foreach( QModelIndex index, aSelectedItems ) {
     aSelectedIndices << index.row();
   }
@@ -406,16 +391,16 @@ bool HYDROGUI_ImportLandCoverMapDlg::getAttrCheckBoxState() const
   return myAttrCheckBox->isChecked();
 }
 
-void HYDROGUI_ImportLandCoverMapDlg::OnComboBoxColorChanged(int theInd)
+void HYDROGUI_ImportLandCoverMapDlg::onComboBoxColorChanged(int theInd)
 {
-  QComboBox* CB = qobject_cast<QComboBox*> (myTableW->cellWidget(theInd, 1));
-  int CurIndOfCB = CB->currentIndex();
-  myTableW->item(theInd, 2)->setBackground(myStrColors[CurIndOfCB]);
+  QComboBox* CB = qobject_cast<QComboBox*> (myCorrTableWidget->cellWidget(theInd, 1));
+  int aCurIndOfCB = CB->currentIndex();
+  myCorrTableWidget->item(theInd, 2)->setBackground(myStrColors[aCurIndOfCB]);
 }
 
-void HYDROGUI_ImportLandCoverMapDlg::setDbfState(bool _state)
+void HYDROGUI_ImportLandCoverMapDlg::setDbfState(bool theState)
 {
-  myDbfState = _state;
+  myDbfState = theState;
 }
 
 bool HYDROGUI_ImportLandCoverMapDlg::getDbfState() const
index ac5503f92d598eb0366f264ca6d420512cb8cc5f..e7992563e586a2e349dd18b6b1964412f9c1d8c5 100644 (file)
@@ -45,10 +45,6 @@ public:
   void                  setPolygonNames( const QStringList& theNames );
   void                  setSelectedPolygonNames( const QStringList& theNames );
   void                  setAttributeNames( const QStringList& theAttrNames );
-  void                  FillCorrTable(const QStringList& theFirstColumn, 
-                                      const QStringList& theSecondColumn,
-                                      const QVector<int> theDefCBIndices,
-                                      const QVector<QColor> theColors);
 
   QStringList           getSelectedPolygonNames() const;
   QString               getSelectedFieldName() const;
@@ -59,14 +55,18 @@ public:
   void                  setFileName( const QString& theFileName );
   QString               getFileName() const;
 
-  void                  setFirstPageState(bool bState);
+  void                  setFirstPageState(bool theState);
   bool                  getAttrCheckBoxState() const;
-  void                  GetAttribute2StricklerCorr(QStringList& AttrValues, QStringList& ST);
+  void                  getValAttr2StricklerTypeCorr(QStringList& theAttrValues, QStringList& theST);
   QVector<int>          getSelectedPolygonIndices() const;
 
-  void                  setDbfState(bool _state);
+  void                  setDbfState(bool theState);
   bool                  getDbfState() const;
 
+  void                  FillCorrespondenceTable(const QStringList& theFirstColumn, 
+                                                const QStringList& theSecondColumn,
+                                                const QVector<int> theDefCBIndices,
+                                                const QVector<QColor> theColors);
 signals:
   void                  FileSelected( const QString& theFileName );
   void                  selectionChanged( const QStringList& );
@@ -75,7 +75,7 @@ protected slots:
   void                  onBrowse();
   void                  onItemSelectionChanged();
   void                  onAttrCBChecked(bool theState);
-  void                  OnComboBoxColorChanged(int theInd);
+  void                  onComboBoxColorChanged(int theInd);
 
 protected:
   bool                  acceptCurrent() const;
@@ -89,18 +89,18 @@ private:
   //First page
   QLineEdit*            myFileName; 
   QGroupBox*            myFileNameGroup;
-  QListWidget*          myPolygons;    
+  QListWidget*          myPolygonsListWidget;          
   QGroupBox*            myObjectNameGroup;
   QLineEdit*            myObjectName;
   QCheckBox*            myAttrCheckBox;
 
   //Second page
-  QListWidget*          myDBFAttr; 
+  QListWidget*          myDBFAttrListWidget
   QLabel*               myAvAttrLabel;
 
   //Third page
-  QLabel*               myCLabel;
-  QTableWidget*         myTableW;
+  QLabel*               myCorrLabel;
+  QTableWidget*         myCorrTableWidget;
 
   //State of the first page
   bool                  myFirstPageState;
index 6274879f8cbb4d2dfb39f67d841399f43633195e..993ac81d86098dd6038357f4e73385747936e727 100644 (file)
@@ -64,7 +64,6 @@
 
 #define MAX_LCM_NAME_INDEX 1000
 
-//TODO add definitions into TS file
 HYDROGUI_ImportLandCoverMapOp::HYDROGUI_ImportLandCoverMapOp( HYDROGUI_Module* theModule )
 : HYDROGUI_Operation( theModule )
 {
@@ -75,23 +74,19 @@ HYDROGUI_ImportLandCoverMapOp::~HYDROGUI_ImportLandCoverMapOp()
 {
   erasePreview();
   myImporter.Free();
-  myAttrV.clear();
+  myAttrValue.clear();
 }
 
 void HYDROGUI_ImportLandCoverMapOp::startOperation()
 {
   HYDROGUI_Operation::startOperation();
 
-  if ( !getPreviewManager() ) {
-    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( 
-                       module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
-  }
+  if ( !getPreviewManager() )
+    setPreviewManager( ::qobject_cast<OCCViewer_ViewManager*>( module()->getApp()->getViewManager( OCCViewer_Viewer::Type(), true ) ) );
 
-  HYDROGUI_ImportLandCoverMapDlg* aPanel = 
-    ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
-  if ( !aPanel ) {
+  HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
+  if ( !aPanel )
     return;
-  }
 
   aPanel->reset();
 }
@@ -166,13 +161,13 @@ void HYDROGUI_ImportLandCoverMapOp::onFileSelected()
         if ( aViewManager && !aCtx.IsNull() )
         {
           HYDROGUI_Shape* aShape = new HYDROGUI_Shape( aCtx, NULL, getPreviewZLayer() );
-          //Green color for now..
-          aShape->setFillingColor(QColor(0,255,0), false, false);
-          aShape->setBorderColor(QColor(0,255,0), false, false);
+          //Preview color is grey
+          aShape->setFillingColor(QColor(50,50,50), false, false);
+          aShape->setBorderColor(QColor(50,50,50), false, false);
           if( !aFace.IsNull() )
             aShape->setShape( aFace);
 
-          myPolygonName2PrsShape.insert( "polygon_" + QString::number(i), aShape);
+          myPolygonName2PrsShape.insert( tr( "DEF_POLYGON_NAME" ) + "_" + QString::number(i), aShape);
         }
       }
 
@@ -186,9 +181,9 @@ void HYDROGUI_ImportLandCoverMapOp::onFileSelected()
       aPanel->setFirstPageState(true); 
       //
       //Try to load DBF-database...
-      QString theDBFFileName;
-      theDBFFileName = myFileName.simplified().replace( ".shp", ".dbf", Qt::CaseInsensitive);
-      bool DBF_Stat = myImporter.DBF_OpenDBF(theDBFFileName);
+      QString aDBFFileName;
+      aDBFFileName = myFileName.simplified().replace( ".shp", ".dbf", Qt::CaseInsensitive);
+      bool DBF_Stat = myImporter.DBF_OpenDBF(aDBFFileName);
       // TODO:
       // add MSG BOX if stat is bad
       if (DBF_Stat)
@@ -204,22 +199,20 @@ void HYDROGUI_ImportLandCoverMapOp::onFileSelected()
       aPanel->setPolygonNames(QStringList());
       aPanel->setObjectName("");
       QApplication::restoreOverrideCursor();
-      QString aMess = "Cannot import land cover;\n";
+      QString aMess = tr( "CANNT_IMPORT_LCM" ) + "\n"; 
       if (aStat == -1)
-        aMess += "Cannot open SHP file";
+        aMess += tr( "CANNT_OPEN_SHP" );
       else if (aStat == -2)
-        aMess += "Cannot open SHX file";
+        aMess += tr( "CANNT_OPEN_SHX" );
       else 
-        aMess += "The shape type of file is " + myImporter.GetShapeTypeName(aShapeTypeOfFile);
+        aMess += tr ("SHP_TYPEFORMAT_MESS") + myImporter.GetShapeTypeName(aShapeTypeOfFile);
       SUIT_MessageBox::warning( module()->getApp()->desktop(), tr( "IMPORT_LANDCOVER" ), aMess);
       commitDocOperation();
       myImporter.Free();
       //abort();
       aPanel->setFirstPageState(false);
     }
-    
   }
-  
 }
 
 HYDROGUI_InputPanel* HYDROGUI_ImportLandCoverMapOp::createInputPanel() const
@@ -247,10 +240,10 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
 
   QStringList aAttrV_T;
   QStringList aSTL;
-  aPanel->GetAttribute2StricklerCorr(aAttrV_T, aSTL);
+  aPanel->getValAttr2StricklerTypeCorr(aAttrV_T, aSTL);
 
   QVector<int> aSelIndices = aPanel->getSelectedPolygonIndices();
-  foreach ( int Ind, aSelIndices ) //check i-base.
+  foreach ( int Ind, aSelIndices )
   {
     TopoDS_Shape aShape = myPolygonFaces(Ind + 1);
     if ( aShape.IsNull() ) 
@@ -258,9 +251,9 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
     QString aST = "";
     if (aPanel->getAttrCheckBoxState())
     {
-      HYDROData_ShapeFile::DBF_AttrValue aV = myAttrV[Ind];
-      int StricklerTypesInd = aAttrV_T.indexOf(QString(aV.myStrVal));
-      aST = aSTL.at(StricklerTypesInd);
+      HYDROData_ShapeFile::DBF_AttrValue aDataVal = myAttrValue[Ind];
+      int aStricklerTypesInd = aAttrV_T.indexOf(QString(aDataVal.myStrVal));
+      aST = aSTL.at(aStricklerTypesInd);
     }
     // else => ST is empty
     aMapFace2ST.Add( TopoDS::Face( aShape ), aST );
@@ -269,9 +262,9 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
   //
   myLCM->StoreLandCovers(aMapFace2ST);
 
-  QString ObjName;
+  QString anObjName;
   if ( !aPanel->getFileName().isEmpty() )
-    ObjName = aPanel->getObjectName();
+    anObjName = aPanel->getObjectName();
   
   Handle_HYDROData_Document aDoc = HYDROData_Document::Document( application()->activeStudy()->id() );
 
@@ -284,13 +277,13 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
       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);
+  QString aNewName = anObjName;
+  for ( int i = 1; i < MAX_LCM_NAME_INDEX && aNameList.contains(aNewName); i++)
+    aNewName = anObjName + "_" + QString::number(i);
 
   if( !myLCM.IsNull() ) 
   {
-    myLCM->SetName( NewName );
+    myLCM->SetName( aNewName );
     myLCM->SetColor( Qt::gray );
     myLCM->Show();
     module()->setIsToUpdate( myLCM );
@@ -300,7 +293,7 @@ bool HYDROGUI_ImportLandCoverMapOp::processApply( int& theUpdateFlags,
 
   erasePreview();
   myImporter.Free();
-  myAttrV.clear();
+  myAttrValue.clear();
 
   return true;
 }
@@ -334,9 +327,8 @@ void HYDROGUI_ImportLandCoverMapOp::onSelectionChanged( const QStringList& theSe
 void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged()
 {
   HYDROGUI_ImportLandCoverMapDlg* aPanel = ::qobject_cast<HYDROGUI_ImportLandCoverMapDlg*>( inputPanel() );
-  if ( !aPanel ) {
+  if ( !aPanel )
     return;
-  }
 
   OCCViewer_ViewManager* aViewManager = getPreviewManager();
   Handle(AIS_InteractiveContext) aCtx = NULL;
@@ -361,9 +353,8 @@ void HYDROGUI_ImportLandCoverMapOp::onViewerSelectionChanged()
 
 void HYDROGUI_ImportLandCoverMapOp::erasePreview()
 {
-  foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape ) {
+  foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape )
     delete aShape;
-  }
 
   myPolygonName2PrsShape.clear();
 }
@@ -388,19 +379,19 @@ void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex )
 
   if (theIndex == 2)
   {
-    //std::vector<HYDROData_ShapeFile::DBF_AttrValue> myAttrV;
-    int Ind = myFieldList.indexOf(aPanel->getSelectedFieldName());
-    if (Ind == -1)
+    //std::vector<HYDROData_ShapeFile::DBF_AttrValue> myAttrValue;
+    int anIndOfSelField = myFieldList.indexOf(aPanel->getSelectedFieldName());
+    if (anIndOfSelField == -1)
       return;
     //aPanel->setSecondPageState(true);
-    myAttrV.clear();
-    myImporter.DBF_GetAttributeList(Ind, myAttrV ); 
+    myAttrValue.clear();
+    myImporter.DBF_GetAttributeList(anIndOfSelField, myAttrValue ); 
 
     mySetOfAttrValues.clear();
-    for (size_t i = 0; i < myAttrV.size(); i++)
+    for (size_t i = 0; i < myAttrValue.size(); i++)
     {
-      HYDROData_ShapeFile::DBF_AttrValue aV = myAttrV[i];
-      mySetOfAttrValues << QString(aV.myStrVal);  //take myStrVal by now..
+      HYDROData_ShapeFile::DBF_AttrValue aV = myAttrValue[i];
+      mySetOfAttrValues << QString(aV.myStrVal);  //take myStrVal for now..
     }
 
     //Collect all strickler_types
@@ -423,38 +414,35 @@ void HYDROGUI_ImportLandCoverMapOp::onNext( const int theIndex )
         }
       }
     }
-    QList<QString> SetOfAttrValuesList = mySetOfAttrValues.toList();
+
+    QList<QString> aSetOfAttrValuesList = mySetOfAttrValues.toList();
     QList<QString> aSTSetList = aSTSet.toList();
-    QVector<QColor> STColors;
-    STColors.reserve(aSTSetList.size());
+    QVector<QColor> aSTColors;
+    aSTColors.reserve(aSTSetList.size());
     foreach (QString str, aSTSetList)
     {
       QColor col = aDoc->GetAssociatedColor(str, NULL);
-      STColors.append (col);
+      aSTColors.append (col);
     }
 
     //add an empty Strickler type
     aSTSetList.prepend(""); 
-    STColors.prepend(QColor(Qt::gray));
+    aSTColors.prepend(QColor(Qt::gray));
     
-    QVector<int> aCurCBIndices(SetOfAttrValuesList.size());
+    QVector<int> aCurCBIndices(aSetOfAttrValuesList.size());
     if (DefStricklerTableObj->GetAttrName() == aPanel->getSelectedFieldName())
-    {
-      for (int i = 0; i < SetOfAttrValuesList.size(); i++)
+      for (int i = 0; i < aSetOfAttrValuesList.size(); i++)
       {
-        QString ST = DefStricklerTableObj->GetType(SetOfAttrValuesList[i]);
-        int IndofSt = aSTSetList.indexOf(ST);
-        aCurCBIndices[i] = IndofSt;
+        QString aST = DefStricklerTableObj->GetType(aSetOfAttrValuesList[i]);
+        int anIndOfSt = aSTSetList.indexOf(aST);
+        aCurCBIndices[i] = anIndOfSt;
       }
-    }
     else
-    {
       //TODO add warning ???
-      for (int i = 0; i < SetOfAttrValuesList.size(); i++)
+      for (int i = 0; i < aSetOfAttrValuesList.size(); i++)
         aCurCBIndices[i] = 0;
-    }
 
-    aPanel->FillCorrTable(SetOfAttrValuesList, aSTSetList, aCurCBIndices, STColors);    
+    aPanel->FillCorrespondenceTable(aSetOfAttrValuesList, aSTSetList, aCurCBIndices, aSTColors);    
   }
 
 }
@@ -474,7 +462,7 @@ void HYDROGUI_ImportLandCoverMapOp::onApply()
   }
   catch (...)
   {
-    SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "LCM_IMPORT_ERROR" ), "Cant import choosed polygons");
+    SUIT_MessageBox::critical( module()->getApp()->desktop(), tr( "LCM_IMPORT_ERROR" ), tr ("CANNT_IMPORT_POLYGONS_FROM_SHP"));
     aResult = false;
   }
   
index b8cfad97aaf38f3421edef0758bfde088b328dc3..1c84c04f3f79b413bb0189358f9463327b5b85b8 100644 (file)
@@ -34,7 +34,6 @@
 class SUIT_FileDlg;
 class HYDROGUI_Shape;
 class TopoDS_Face;
-//class HYDROData_LandCoverMap;
 #include <HYDROData_LandCoverMap.h>
 
 class HYDROGUI_ImportLandCoverMapOp : public HYDROGUI_Operation
@@ -64,11 +63,11 @@ protected slots:
 private:
   QMap<QString, HYDROGUI_Shape*> myPolygonName2PrsShape;
   TopTools_SequenceOfShape myPolygonFaces;
-  QSet<QString> mySetOfAttrValues;
   HYDROData_ShapeFile myImporter;
   QString myFileName;
   QStringList myFieldList;
-  std::vector<HYDROData_ShapeFile::DBF_AttrValue> myAttrV;
+  std::vector<HYDROData_ShapeFile::DBF_AttrValue> myAttrValue;
+  QSet<QString> mySetOfAttrValues;
   Handle(HYDROData_LandCoverMap) myLCM;
 };
 
index 4ce8f6d653300c0fe853ba5a4eb7d216b17bc601..3605689b554b8a554af7ddf0a09f8aaf29852492 100644 (file)
@@ -2322,13 +2322,52 @@ file cannot be correctly imported for an Obstacle definition.</translation>
       <translation>Founded polygons:</translation>
     </message>
     <message>
-      <source>BAD_IMPORTED_LANDCOVERMAP_FILES</source>
-      <translation>Land cover map import error</translation>
+      <source>USE_DBF_AS_ST</source>
+      <translation>Use dBase attributes as a Strickler Types</translation>
     </message>
     <message>
-      <source>NO_ONE_LANDCOVERMAP_IMPORTED</source>
-      <translation>Land cover map cannot be read from seleted file</translation>
+      <source>AV_ATTRS</source>
+      <translation>Available attributes</translation>
     </message>
+    <message>
+      <source>CORR</source>
+      <translation>Correspondence</translation>
+    </message>
+
+    <message>
+      <source>TABLE_H1</source>
+      <translation>Attribute</translation>
+    </message>
+    <message>
+      <source>TABLE_H2</source>
+      <translation>Strickler Type</translation>
+    </message>
+    <message>
+      <source>TABLE_H3</source>
+      <translation>Color</translation>
+    </message>
+
+    <message>
+      <source>LCM_IMPORT_WARNING</source>
+      <translation>Import of Land cover map</translation>
+    </message>
+    <message>
+      <source>DBF_LOAD_ERROR</source>
+      <translation>Cannot load DBF file</translation>
+    </message>
+    <message>
+      <source>FILE_ISNT_CHOSEN</source>
+      <translation>File isn't chosen</translation>
+    </message>
+    <message>
+      <source>POLYGONS_ISNT_SELECTED</source>
+      <translation>Polygons isn't selected</translation>
+    </message>
+    <message>
+      <source>DBF_LOAD_ERR_MESS</source>
+      <translation>Cant open DBF file or it's corrupted</translation>
+    </message>
+
   </context>
 
   <context>
@@ -2341,7 +2380,45 @@ file cannot be correctly imported for an Obstacle definition.</translation>
       <source>DEFAULT_LANDCOVER_MAP_NAME</source>
       <translation>Landcovermap_0</translation>
     </message>
+    <message>
+      <source>DEF_POLYGON_NAME</source>
+      <translation>polygon</translation>
+    </message>
+
+    <message>
+      <source>CANNT_IMPORT_LCM</source>
+      <translation>Cannot import land cover map;</translation>
+    </message>
+    <message>
+      <source>CANNT_OPEN_SHP</source>
+      <translation>Cannot open SHP file</translation>
+    </message>
+    <message>
+      <source>CANNT_OPEN_SHX</source>
+      <translation>Cannot open SHX file</translation>
+    </message>
+    <message>
+      <source>SHP_TYPEFORMAT_MESS</source>
+      <translation>The shape type of file is </translation>
+    </message>
+    <message>
+      <source>CANNT_IMPORT_POLYGONS_FROM_SHP</source>
+      <translation>Cant import choosed polygons</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_ExportLandCoverMapDlg</name>
+    <message>
+      <source>EXPORT_LANDCOVERMAP</source>
+      <translation>Export land cover map to SHP file</translation>
+    </message>
+    <message>
+      <source>WRITE_ST_AS_ATTRS_TO_DBF</source>
+      <translation>Write Strickler Types as attributes values to DBF file</translation>
+    </message>
   </context>
+
  
   <context>
     <name>HYDROGUI_ImportSinusXOp</name>