Salome HOME
projects
/
modules
/
hydro.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Exlude the user input during process events by application (Bug #325).
[modules/hydro.git]
/
src
/
HYDROGUI
/
HYDROGUI_GeoreferencementDlg.cxx
diff --git
a/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx
b/src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx
index feb21b2952b59011ae47672af27949f1bc255f9d..7bb035f06bf3e14b3a461239f8b7386c395859a2 100644
(file)
--- a/
src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx
+++ b/
src/HYDROGUI/HYDROGUI_GeoreferencementDlg.cxx
@@
-22,7
+22,9
@@
#include "HYDROGUI_GeoreferencementDlg.h"
#include "HYDROGUI_GeoreferencementDlg.h"
-#include <GEOMUtils.hxx>
+#include "HYDROGUI_Tool.h"
+
+#include <CurveCreator_Utils.h>
#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewManager.h>
#include <OCCViewer_ViewWindow.h>
#include <OCCViewer_ViewManager.h>
@@
-34,6
+36,7
@@
#include <QItemDelegate>
#include <QHeaderView>
#include <QRadioButton>
#include <QItemDelegate>
#include <QHeaderView>
#include <QRadioButton>
+#include <QPushButton>
#include <QLineEdit>
#include <QButtonGroup>
#include <QGroupBox>
#include <QLineEdit>
#include <QButtonGroup>
#include <QGroupBox>
@@
-42,9
+45,11
@@
//! Profile data structre constructor
HYDROGUI_GeoreferencementDlg::ProfileGeoData::ProfileGeoData(
//! Profile data structre constructor
HYDROGUI_GeoreferencementDlg::ProfileGeoData::ProfileGeoData(
+ const QString& theName,
const QString& theXg, const QString& theYg,
const QString& theXd, const QString& theYd)
{
const QString& theXg, const QString& theYg,
const QString& theXd, const QString& theYd)
{
+ this->Name = theName;
this->isEmpty = theXg.isEmpty() && theYg.isEmpty() &&
theXd.isEmpty() && theYd.isEmpty();
this->isIncomplete = !isEmpty;
this->isEmpty = theXg.isEmpty() && theYg.isEmpty() &&
theXd.isEmpty() && theYd.isEmpty();
this->isIncomplete = !isEmpty;
@@
-92,7
+97,10
@@
QWidget* HYDROGUI_GeoreferencementDlg::Delegate::createEditor(
if ( theIndex.column() > 0 ) {
QLineEdit* aLineEdit = new QLineEdit( theParent );
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 );
anEditor = aLineEdit;
} else {
anEditor = QItemDelegate::createEditor( theParent, theOption, theIndex );
@@
-122,7
+130,7
@@
void HYDROGUI_GeoreferencementDlg::Delegate::setModelData(
}
HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* theModule, const QString& theTitle )
}
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 );
{
// Mode selector (all/selected)
QGroupBox* aModeGroup = new QGroupBox( tr( "PROFILES" ), this );
@@
-140,6
+148,13
@@
HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* the
aModeSelectorLayout->addWidget( anAllRB );
aModeSelectorLayout->addWidget( aSelectedRB );
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 ) );
// Table
myTable = new QTableWidget( mainFrame() );
myTable->setItemDelegate( new Delegate( this ) );
@@
-154,10
+169,14
@@
HYDROGUI_GeoreferencementDlg::HYDROGUI_GeoreferencementDlg( HYDROGUI_Module* the
// Layout
addWidget( aModeGroup );
// Layout
addWidget( aModeGroup );
+ addLayout( anUpdateSelLayout );
addWidget( myTable );
// Connect signals and slots
connect( myModeButtons, SIGNAL( buttonClicked( int ) ), this, SLOT( onModeActivated( int ) ) );
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()
}
HYDROGUI_GeoreferencementDlg::~HYDROGUI_GeoreferencementDlg()
@@
-166,6
+185,7
@@
HYDROGUI_GeoreferencementDlg::~HYDROGUI_GeoreferencementDlg()
void HYDROGUI_GeoreferencementDlg::onModeActivated( int theMode )
{
void HYDROGUI_GeoreferencementDlg::onModeActivated( int theMode )
{
+ myUpdateSelBtn->setEnabled( theMode == SelectedProfiles );
emit modeActivated( theMode );
}
emit modeActivated( theMode );
}
@@
-187,27
+207,31
@@
void HYDROGUI_GeoreferencementDlg::setMode( const int theMode )
aModeButton->setChecked( true );
}
aModeButton->setChecked( true );
}
+ myUpdateSelBtn->setEnabled( theMode == SelectedProfiles );
+
myModeButtons->blockSignals( isBlocked );
}
myModeButtons->blockSignals( isBlocked );
}
-void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoData
Map& theMap
)
+void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoData
List& theData
)
{
{
+ disconnect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ),
+ this, SLOT( onDataChanged() ) );
+
myTable->setRowCount( 0 );
myTable->setRowCount( 0 );
- foreach ( const
QString& aProfileName, theMap.keys()
) {
+ foreach ( const
ProfileGeoData& aGeoData, theData
) {
// Check the current profile name
// Check the current profile name
- if ( a
Profile
Name.isEmpty() ) {
+ if ( a
GeoData.
Name.isEmpty() ) {
continue;
}
// Get georeferencement data for the current profile
continue;
}
// Get georeferencement data for the current profile
- ProfileGeoData aGeoData = theMap.value( aProfileName );
QString aXg, anYg, aXd, anYd;
if ( !aGeoData.isEmpty ) {
QString aXg, anYg, aXd, anYd;
if ( !aGeoData.isEmpty ) {
- aXg =
get
String( aGeoData.Xg );
- anYg =
get
String( aGeoData.Yg );
- aXd =
get
String( aGeoData.Xd );
- anYd =
get
String( aGeoData.Yd );
+ aXg =
HYDROGUI_Tool::GetCoordinate
String( aGeoData.Xg );
+ anYg =
HYDROGUI_Tool::GetCoordinate
String( aGeoData.Yg );
+ aXd =
HYDROGUI_Tool::GetCoordinate
String( aGeoData.Xd );
+ anYd =
HYDROGUI_Tool::GetCoordinate
String( aGeoData.Yd );
}
// Insert row with the data
}
// Insert row with the data
@@
-215,11
+239,13
@@
void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap )
myTable->insertRow( aRow );
// "Profile" column
myTable->insertRow( aRow );
// "Profile" column
- QTableWidgetItem* aNameItem = new QTableWidgetItem( aProfileName );
- aNameItem->setFlags( Qt::ItemIsEnabled );
+ QTableWidgetItem* aNameItem = new QTableWidgetItem( aGeoData.Name );
+ aNameItem->setFlags( aNameItem->flags() & ~Qt::ItemIsEnabled );
+ /* Bold font is not used in other tables. Keep the common style.
QFont aFont = aNameItem->font();
aFont.setBold( true );
QFont aFont = aNameItem->font();
aFont.setBold( true );
- aNameItem->setFont( aFont );
+ aNameItem->setFont( aFont );
+ */
myTable->setItem( aRow, 0, aNameItem );
// "Xg" column
myTable->setItem( aRow, 0, aNameItem );
// "Xg" column
@@
-236,12
+262,18
@@
void HYDROGUI_GeoreferencementDlg::setData( const ProfilesGeoDataMap& theMap )
}
myTable->resizeColumnToContents( 0 );
}
myTable->resizeColumnToContents( 0 );
+ myTable->resizeRowsToContents();
+
+ myIsModified = false;
+
+ connect( myTable->model(), SIGNAL( dataChanged ( const QModelIndex&, const QModelIndex& ) ),
+ this, SLOT( onDataChanged() ) );
}
}
-void HYDROGUI_GeoreferencementDlg::getData( ProfilesGeoData
Map& theMap )
+void HYDROGUI_GeoreferencementDlg::getData( ProfilesGeoData
List& theData ) const
{
{
- // Clear the
map
- the
Map
.clear();
+ // Clear the
list
+ the
Data
.clear();
// Fill the map
bool isOk = false;
// Fill the map
bool isOk = false;
@@
-254,7
+286,7
@@
void HYDROGUI_GeoreferencementDlg::getData( ProfilesGeoDataMap& theMap )
aXd = myTable->item( aRow, 3 )->text();
anYd = myTable->item( aRow, 4 )->text();
aXd = myTable->item( aRow, 3 )->text();
anYd = myTable->item( aRow, 4 )->text();
- the
Map.insert( aProfileName, ProfileGeoData(
aXg, anYg, aXd, anYd ) );
+ the
Data.append( ProfileGeoData( aProfileName,
aXg, anYg, aXd, anYd ) );
}
}
}
}
@@
-277,18
+309,25
@@
void HYDROGUI_GeoreferencementDlg::onMousePress(
// Get the selected point coordinates
OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort();
// Get the selected point coordinates
OCCViewer_ViewPort3d* aViewPort = anOCCViewWindow->getViewPort();
- gp_Pnt aPnt =
GEOM
Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(),
- aViewPort->getView() );
+ gp_Pnt aPnt =
CurveCreator_
Utils::ConvertClickToPoint( theEvent->x(), theEvent->y(),
+
aViewPort->getView() );
// Set the coordinates to the corresponding cells of the table
int aColumnX = aColumn < 3 ? 1 : 3;
int aColumnY = aColumnX + 1;
// Set the coordinates to the corresponding cells of the table
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
}
\ No newline at end of file