#include <QCheckBox>
HYDROGUI_ImportBathymetryDlg::HYDROGUI_ImportBathymetryDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle ), myIsEdit ( false )
{
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
// Import bathymetry from file
myFileNameGroup = new QGroupBox( tr( "IMPORT_BATHYMETRY_FROM_FILE" ) );
- QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), myFileNameGroup );
+ QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAMES" ), myFileNameGroup );
myFileNames = new QListWidget( myFileNameGroup );
+ myFileNames->setSelectionMode( QAbstractItemView::ExtendedSelection);
//myFileNames->viewport()->setAttribute( Qt::WA_TransparentForMouseEvents );
//myFileNames->setFocusPolicy(Qt::FocusPolicy::NoFocus);
QPushButton* aBrowseBtn = new QPushButton( myFileNameGroup );
- aBrowseBtn->setText("Load files(s)");
+ aBrowseBtn->setText("Add files(s)");
aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
+ QPushButton* aRemoveBtn = new QPushButton( myFileNameGroup );
+ aRemoveBtn->setText("Remove selected file(s)");
+
QBoxLayout* aFileNameLayout = new QVBoxLayout( myFileNameGroup );
myFuseIntoOne = new QCheckBox();
- myFuseIntoOne->setText("Import as one bathemetry object (fuse the geometry data)");
+ myFuseIntoOne->setText("Import as one bathymetry object (fuse the geometry data)");
myFuseIntoOne->setEnabled( false );
aFileNameLayout->setMargin( 5 );
aFileNameLayout->setSpacing( 5 );
aFileNameLayout->addWidget( aFileNameLabel );
aFileNameLayout->addWidget( aBrowseBtn );
+ aFileNameLayout->addWidget( aRemoveBtn );
aFileNameLayout->addWidget( myFileNames );
aFileNameLayout->addWidget( myFuseIntoOne );
addStretch();
connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
+ connect( aRemoveBtn, SIGNAL( clicked() ), this, SLOT( onRemove() ) );
connect( myFuseIntoOne, SIGNAL( stateChanged(int) ), this, SLOT( onStateChanged(int) ) );
}
myFuseIntoOne->setEnabled( false );
}
+void HYDROGUI_ImportBathymetryDlg::SetEditMode(bool isEdit)
+{
+ myIsEdit = isEdit;
+}
+
void HYDROGUI_ImportBathymetryDlg::setObjectName( const QString& theName )
{
myObjectName->setText( theName );
return myObjectName->text();
}
-void HYDROGUI_ImportBathymetryDlg::setFileNames( const QStringList& theFileNames )
+void HYDROGUI_ImportBathymetryDlg::addFileNames( const QStringList& theFileNames )
{
- myFileNames->clear();
- myFileNames->addItems( theFileNames );
+ //myFileNames->clear();
+ QSet<QString> exfilenames = getFileNames().toSet();
+ QStringList newFileNames;
+ foreach (QString str, theFileNames)
+ if (!exfilenames.contains(str))
+ newFileNames.append(str);
+ myFileNames->addItems( newFileNames );
+ UpdateCheckBoxStates();
+}
- if (myFuseIntoOne->isChecked() || theFileNames.count() == 1 )
+void HYDROGUI_ImportBathymetryDlg::removeFileNames( const QList<QListWidgetItem*>& theFileNamesToRem )
+{
+ foreach (QListWidgetItem* item, theFileNamesToRem)
+ delete myFileNames->takeItem(myFileNames->row(item));
+ UpdateCheckBoxStates();
+}
+
+
+void HYDROGUI_ImportBathymetryDlg::UpdateCheckBoxStates()
+{
+ if (myFuseIntoOne->isChecked() || myFileNames->count() == 1 )
{
myObjectNameGroup->setEnabled( true );
myObjectName->setEnabled( true );
myObjectName->setEnabled( false );
}
//
- if (theFileNames.count() == 1)
+ if (myFileNames->count() <= 1 || myIsEdit)
myFuseIntoOne->setEnabled( false );
- else if (theFileNames.count() > 1)
+ else
myFuseIntoOne->setEnabled( true );
+ QString anObjectName = getObjectName().simplified();
+
+ QStringList aFileNames = getFileNames();
+ if ( anObjectName.isEmpty() )
+ {
+ if (!aFileNames.empty())
+ {
+ anObjectName = aFileNames[0];
+ if ( !anObjectName.isEmpty() )
+ anObjectName = QFileInfo( anObjectName ).baseName();
+ }
+ setObjectName( anObjectName );
+ }
+
}
QStringList HYDROGUI_ImportBathymetryDlg::getFileNames() const
if( !aFileNames.isEmpty() )
{
- setFileNames( aFileNames );
+ addFileNames( aFileNames );
emit FileSelected( aFileNames );
}
}
+void HYDROGUI_ImportBathymetryDlg::onRemove()
+{
+ QList<QListWidgetItem*> selected = myFileNames->selectedItems();
+
+ removeFileNames(selected);
+}
+
void HYDROGUI_ImportBathymetryDlg::onStateChanged (int state)
{
if (getFileNames().count() > 1)
#include "HYDROGUI_InputPanel.h"
#include <QMap>
+#include <QList>
class QGroupBox;
class QLineEdit;
class QCheckBox;
class QListWidget;
class QStringList;
+class QListWidgetItem;
class HYDROGUI_ImportBathymetryDlg : public HYDROGUI_InputPanel
{
void setObjectName( const QString& theName );
QString getObjectName() const;
- void setFileNames( const QStringList& theFileName );
+ //void setFileNames( const QStringList& theFileName );
QStringList getFileNames() const;
+ void addFileNames( const QStringList& theFileNames );
+ void removeFileNames( const QList<QListWidgetItem*>& theFileNamesToRem );
+ void UpdateCheckBoxStates();
void setInvertAltitudes( const bool theIsInvert );
bool isInvertAltitudes() const;
bool isFuseIntoOneOptionChecked() const;
void setFuseIntoOneOptionEnabled(bool enabled);
bool isFuseIntoOneOptionEnabled() const;
-
+
+ void SetEditMode(bool isEdit);
+
signals:
void FileSelected( const QStringList& theFileName );
protected slots:
void onBrowse();
+ void onRemove();
void onStateChanged (int state);
private:
QGroupBox* myObjectNameGroup;
QLineEdit* myObjectName;
+
+ bool myIsEdit;
};
#endif
return;
aPanel->reset();
+ aPanel->SetEditMode(myIsEdit);
if( myIsEdit )
{
aPanel->setFuseIntoOneOptionChecked( true );
aPanel->setObjectName( aName );
- aPanel->setFileNames( aFileNames );
+ aPanel->addFileNames( aFileNames );
aPanel->setInvertAltitudes( anIsAltitudesInverted );
aPanel->setFuseIntoOneOptionEnabled( false );
}
if (!inexistWarn.isNull())
SUIT_MessageBox::warning( module()->getApp()->desktop(),
- tr( "BATHEMETRY_IMPORT_WARNING" ), "Can't read the next files:" + inexistWarn );
+ tr( "BATHYMETRY_IMPORT_WARNING" ), "Can't read the next files:" + inexistWarn );
aFileNames = DummyFileList;
if (myEditedObject.IsNull())
return false;
QStringList anOldFileNames = myEditedObject->GetFilePaths();
- bool anIsInvertAltitudes = aPanel->isInvertAltitudes();
- myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, false );
+ //bool anIsInvertAltitudes = aPanel->isInvertAltitudes();
+ //myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, false );
if ( aFileNames.toSet() != anOldFileNames.toSet() )
{
- myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, false );
+ myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, true );
if ( !myEditedObject->ImportFromFiles( aFileNames ) )
{
theErrorMsg = tr( "BAD_IMPORTED_BATHYMETRY_FILE" ).arg( aFileNames.join("\n") );
}
}
else if ( anIsInvertAltitudes != myEditedObject->IsAltitudesInverted() )
- myEditedObject->SetAltitudesInverted( anIsInvertAltitudes );
+ myEditedObject->SetAltitudesInverted( anIsInvertAltitudes, true );
- QString aNewObjName;
- if (CheckNameExistingBathy(anObjectName, aNewObjName))
- {
- myEditedObject->SetName( aNewObjName );
- replacemWarn += "\n'" + anObjectName + "' => '" + aNewObjName + "'";
- }
- else
- myEditedObject->SetName( anObjectName );
+ myEditedObject->SetName( anObjectName );
myEditedObject->Update();
}
else
if (!UnreadFilesWarn.isNull())
SUIT_MessageBox::warning( module()->getApp()->desktop(),
- tr( "BATHEMETRY_IMPORT_WARNING" ), "The next files cannot be imported:" + UnreadFilesWarn );
+ tr( "BATHYMETRY_IMPORT_WARNING" ), "The next files cannot be imported:" + UnreadFilesWarn );
if (!replacemWarn.isNull())
SUIT_MessageBox::warning( module()->getApp()->desktop(),
- tr( "BATHEMETRY_IMPORT_WARNING" ), "The next objects names are already exist in the document; so the new objects was renamed:" + replacemWarn );
+ tr( "BATHYMETRY_IMPORT_WARNING" ), "The next objects names are already exist in the document; so the new objects was renamed:" + replacemWarn );
// Activate VTK viewer and show the bathymetry
SUIT_ViewManager* aVTKMgr = 0;
if ( !aPanel )
return;
- QStringList aFileNames = aPanel->getFileNames();
- if ( !aPanel->isFuseIntoOneOptionEnabled() )
- aPanel->setFuseIntoOneOptionEnabled( !myIsEdit && aFileNames.count() > 1 );
-
- QString anObjectName = aPanel->getObjectName().simplified();
- if ( anObjectName.isEmpty() )
- {
- if (aFileNames.count() == 1)
- {
- anObjectName = aFileNames[0];
- if ( !anObjectName.isEmpty() )
- anObjectName = QFileInfo( anObjectName ).baseName();
- }
-
- if ( anObjectName.isEmpty() ) {
- anObjectName = HYDROGUI_Tool::GenerateObjectName( module(), tr( "DEFAULT_BATHYMETRY_NAME" ) );
- }
- aPanel->setObjectName( anObjectName );
- }
+ aPanel->UpdateCheckBoxStates();
}
bool HYDROGUI_ImportBathymetryOp::CheckNameExistingBathy(const QString& InpName, QString& OutputName)
<translation>Files list is empty</translation>
</message>
<message>
- <source>BATHEMETRY_IMPORT_WARNING</source>
- <translation>Imort of bahemetry - warning</translation>
+ <source>BATHYMETRY_IMPORT_WARNING</source>
+ <translation>Import of bahemetry - warning</translation>
</message>
<message>
<translation>Bathymetry name</translation>
</message>
<message>
- <source>FILE_NAME</source>
- <translation>File name</translation>
+ <source>FILE_NAMES</source>
+ <translation>File names</translation>
</message>
<message>
<source>IMPORT_BATHYMETRY_FROM_FILE</source>