#include "HYDROGUI_GeoreferencementDlg.h"
+#include "HYDROGUI_Tool.h"
+
#include <GEOMUtils.hxx>
#include <OCCViewer_ViewWindow.h>
#include <QItemDelegate>
#include <QHeaderView>
#include <QRadioButton>
+#include <QPushButton>
#include <QLineEdit>
#include <QButtonGroup>
#include <QGroupBox>
if ( theIndex.column() > 0 ) {
QLineEdit* aLineEdit = new QLineEdit( theParent );
- aLineEdit->setValidator( new QDoubleValidator( aLineEdit ) );
+ QDoubleValidator* aDoubleValidator = new QDoubleValidator();
+ aDoubleValidator->setNotation( QDoubleValidator::StandardNotation );
+ aDoubleValidator->setDecimals( 2 );
+ aLineEdit->setValidator( aDoubleValidator );
anEditor = aLineEdit;
} else {
anEditor = QItemDelegate::createEditor( theParent, theOption, theIndex );
}
HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* theModule, const QString& theTitle )
-: HYDROGUI_InputPanel( theModule, theTitle )
+: HYDROGUI_InputPanel( theModule, theTitle ), myIsModified( false )
{
// Mode selector (all/selected)
QGroupBox* aModeGroup = new QGroupBox( tr( "PROFILES" ), this );
aModeSelectorLayout->addWidget( anAllRB );
aModeSelectorLayout->addWidget( aSelectedRB );
+ // Update selection button
+ myUpdateSelBtn = new QPushButton( mainFrame() );
+ myUpdateSelBtn->setText( tr("UPDATE_SELECTION") );
+ QBoxLayout* anUpdateSelLayout = new QHBoxLayout( mainFrame() );
+ anUpdateSelLayout->addWidget( myUpdateSelBtn );
+ anUpdateSelLayout->addStretch();
+
// Table
myTable = new QTableWidget( mainFrame() );
myTable->setItemDelegate( new Delegate( this ) );
// Layout
addWidget( aModeGroup );
+ addLayout( anUpdateSelLayout );
addWidget( myTable );
// Connect signals and slots
connect( myModeButtons, SIGNAL( buttonClicked( int ) ), this, SLOT( onModeActivated( int ) ) );
+ connect( myUpdateSelBtn, SIGNAL( clicked() ), this, SIGNAL( updateSelection() ) );
+ connect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ),
+ this, SLOT( onDataChanged() ) );
}
HYDROGUI_GeoreferencementDlg::~HYDROGUI_GeoreferencementDlg()
void HYDROGUI_GeoreferencementDlg::onModeActivated( int theMode )
{
+ myUpdateSelBtn->setEnabled( theMode == SelectedProfiles );
emit modeActivated( theMode );
}
aModeButton->setChecked( true );
}
+ myUpdateSelBtn->setEnabled( theMode == SelectedProfiles );
+
myModeButtons->blockSignals( isBlocked );
}
void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap )
{
+ disconnect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ),
+ this, SLOT( onDataChanged() ) );
+
myTable->setRowCount( 0 );
foreach ( const QString& aProfileName, theMap.keys() ) {
ProfileGeoData aGeoData = theMap.value( aProfileName );
QString aXg, anYg, aXd, anYd;
if ( !aGeoData.isEmpty ) {
- aXg = getString( aGeoData.Xg );
- anYg = getString( aGeoData.Yg );
- aXd = getString( aGeoData.Xd );
- anYd = getString( aGeoData.Yd );
+ aXg = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xg );
+ anYg = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yg );
+ aXd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Xd );
+ anYd = HYDROGUI_Tool::GetCoordinateString( aGeoData.Yd );
}
// Insert row with the data
}
myTable->resizeColumnToContents( 0 );
+ myTable->resizeRowsToContents();
+
+ myIsModified = false;
+
+ connect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ),
+ this, SLOT( onDataChanged() ) );
}
void HYDROGUI_GeoreferencementDlg::getData( ProfilesGeoDataMap& theMap )
int aColumnX = aColumn < 3 ? 1 : 3;
int aColumnY = aColumnX + 1;
- myTable->item( aRow, aColumnX )->setText( getString( aPnt.X() ) );
- myTable->item( aRow, aColumnY )->setText( getString( aPnt.Y() ) );
+ QString aXStr = HYDROGUI_Tool::GetCoordinateString( aPnt.X() );
+ QString anYStr = HYDROGUI_Tool::GetCoordinateString( aPnt.Y() );
+ myTable->item( aRow, aColumnX )->setText( aXStr );
+ myTable->item( aRow, aColumnY )->setText( anYStr );
+}
+
+void HYDROGUI_GeoreferencementDlg::onDataChanged()
+{
+ myIsModified = true;
}
-QString HYDROGUI_GeoreferencementDlg::getString( const double theNumber ) const
+bool HYDROGUI_GeoreferencementDlg::isModified() const
{
- return QString::number( theNumber, 'g', 12 );
+ return myIsModified;
}
\ No newline at end of file