//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
#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 );
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:
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
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)));
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;
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;
}
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 );
}
{
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" ) );
}
-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;
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());
}
}
{
QVector<int> aSelectedIndices;
- QModelIndexList aSelectedItems = myPolygons->selectionModel()->selectedIndexes();
+ QModelIndexList aSelectedItems = myPolygonsListWidget->selectionModel()->selectedIndexes();
foreach( QModelIndex index, aSelectedItems ) {
aSelectedIndices << index.row();
}
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
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;
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& );
void onBrowse();
void onItemSelectionChanged();
void onAttrCBChecked(bool theState);
- void OnComboBoxColorChanged(int theInd);
+ void onComboBoxColorChanged(int theInd);
protected:
bool acceptCurrent() const;
//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;
#define MAX_LCM_NAME_INDEX 1000
-//TODO add definitions into TS file
HYDROGUI_ImportLandCoverMapOp::HYDROGUI_ImportLandCoverMapOp( HYDROGUI_Module* theModule )
: HYDROGUI_Operation( theModule )
{
{
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();
}
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);
}
}
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)
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
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() )
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 );
//
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() );
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 );
erasePreview();
myImporter.Free();
- myAttrV.clear();
+ myAttrValue.clear();
return true;
}
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;
void HYDROGUI_ImportLandCoverMapOp::erasePreview()
{
- foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape ) {
+ foreach ( HYDROGUI_Shape* aShape, myPolygonName2PrsShape )
delete aShape;
- }
myPolygonName2PrsShape.clear();
}
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
}
}
}
- 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);
}
}
}
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;
}
class SUIT_FileDlg;
class HYDROGUI_Shape;
class TopoDS_Face;
-//class HYDROData_LandCoverMap;
#include <HYDROData_LandCoverMap.h>
class HYDROGUI_ImportLandCoverMapOp : public HYDROGUI_Operation
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;
};
<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>
<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>