From: rkv Date: Wed, 13 Nov 2013 15:38:00 +0000 (+0000) Subject: Fix for the bug #42: point C is not activated, but point C is shown in preview in... X-Git-Tag: BR_hydro_v_0_3~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=de7cf9bb0a7a41d6487013c87f4a54d0664cd303;p=modules%2Fhydro.git Fix for the bug #42: point C is not activated, but point C is shown in preview in Transform image view --- diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx index 1d9510f4..74fcfc1c 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -288,7 +288,7 @@ HYDROGUI_ImportImageDlg::HYDROGUI_ImportImageDlg( HYDROGUI_Module* theModule, co connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointXMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); connect( myPointCEnabler, SIGNAL( toggled( bool ) ), myRefPointYMap[ HYDROGUI_PrsImage::PointC ], SLOT( setEnabled( bool ) ) ); - connect( myPointCEnabler, SIGNAL( toggled( bool ) ), SIGNAL( setIsByTwoPoints( bool ) ) ); + connect( myPointCEnabler, SIGNAL( toggled( bool ) ), SLOT( onSetCIsUsed( bool ) ) ); aTransformLayout->setColumnStretch( 1, 1 ); // double aTransformLayout->setColumnStretch( 3, 1 ); // degrees @@ -318,6 +318,16 @@ HYDROGUI_ImportImageDlg::~HYDROGUI_ImportImageDlg() { } +void HYDROGUI_ImportImageDlg::onSetCIsUsed( bool theCIsUsed ) +{ + if ( !theCIsUsed && myPointBtnMap[ HYDROGUI_PrsImage::PointC ]->isChecked() ) + { + // Turn on point A selection if point C selection has been activated and we disable point C. + myPointBtnMap[ HYDROGUI_PrsImage::PointA ]->toggle(); + } + emit setCIsUsed( theCIsUsed ); +} + void HYDROGUI_ImportImageDlg::setIsEdit( const bool theIsEdit ) { myFileNameGroup->setVisible( !theIsEdit ); diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h index 59de8c6c..12c550f9 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h @@ -118,6 +118,7 @@ protected slots: void onRefImageActivated( const QString& ); void onPointBtnToggled( bool ); void onPointCoordChanged( int ); + void onSetCIsUsed( bool theCIsUsed ); void onGeodesicCoordChanged(); void onGeodesicCoordChanged( const int thePointType ); @@ -138,7 +139,7 @@ signals: int theValue ); void modeActivated( int ); void refImageActivated( const QString& ); - void setIsByTwoPoints( bool theIsByTwoPoints ); + void setCIsUsed( bool theIsByTwoPoints ); private: QGroupBox* myFileNameGroup; //!< The group for the source image file selection diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx index 82de7403..4f7afb9b 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -270,19 +270,19 @@ HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const connect( aPanel, SIGNAL( modeActivated( int ) ), SLOT( onModeActivated( int ) ) ); connect( aPanel, SIGNAL( refImageActivated( const QString& ) ), SLOT( onRefImageActivated( const QString& ) ) ); - connect( aPanel, SIGNAL( setIsByTwoPoints( bool ) ), SLOT( onSetIsByTwoPoints( bool ) ) ); + connect( aPanel, SIGNAL( setCIsUsed( bool ) ), SLOT( onSetCIsUsed( bool ) ) ); return aPanel; } -void HYDROGUI_ImportImageOp::onSetIsByTwoPoints( bool theIsSetByTwoPoints ) +void HYDROGUI_ImportImageOp::onSetCIsUsed( bool theCIsUsed ) { if ( myPreviewPrs ) { - myPreviewPrs->setIsByTwoPoints( theIsSetByTwoPoints ); + myPreviewPrs->setIsByTwoPoints( !theCIsUsed ); } if ( myRefPreviewPrs ) { - myRefPreviewPrs->setIsByTwoPoints( theIsSetByTwoPoints ); + myRefPreviewPrs->setIsByTwoPoints( !theCIsUsed ); } } @@ -700,6 +700,7 @@ void HYDROGUI_ImportImageOp::onPointSelected( bool theIsRefImage ) const HYDROGUI_PrsImage::TransformationPointMap& aPointMap = aPrs->getTransformationPointMap(); + HYDROGUI_PrsImage::TransformationPointMapIterator anIter( aPointMap ); while( anIter.hasNext() ) { diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index ade48517..e14249d5 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -57,7 +57,7 @@ protected slots: void onPointCoordChanged( bool, int, bool, int ); void onModeActivated( int ); void onRefImageActivated( const QString& ); - void onSetIsByTwoPoints( bool theIsSetByTwoPoints ); + void onSetCIsUsed( bool theCIsUsed ); void onLastViewClosed( SUIT_ViewManager* ); diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx index 250d4c85..172f5f72 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -298,6 +298,7 @@ void HYDROGUI_PrsImage::computeTransformationPoints() int aWidth = myImage.width(); int aHeight = myImage.height(); + // Create presentations for transformation points A, B and C for( int aPointType = PointA; aPointType <= PointC; aPointType++ ) { TransformationPoint aTransformationPoint; @@ -341,29 +342,37 @@ void HYDROGUI_PrsImage::computeTransformationPoints() } } - bool anIsVisible = myIsTransformationPointPreview; - bool anIsPointVisible; for( int aPointType = PointA; aPointType <= PointC; aPointType++ ) { - // If image is transformed only by two points then the point C is invisible - anIsPointVisible = anIsVisible && ( - ( !myIsByTwoPoints ) || ( myIsByTwoPoints && ( aPointType != PointC ) ) ); - TransformationPoint& aTransformationPoint = myTransformationPointMap[ aPointType ]; - - double aRadius = 5; - const QPointF& aPoint = aTransformationPoint.Point; - QRectF aRect( aPoint - QPointF( aRadius, aRadius ), QSizeF( aRadius * 2 + 1, aRadius * 2 + 1 ) ); - aTransformationPoint.PointItem->setRect( aRect ); - aTransformationPoint.PointItem->setVisible( anIsPointVisible ); - - QPointF aCaptionShift( -aRadius * 2, aRadius * 2 ); - aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift ); - aTransformationPoint.CaptionItem->setVisible( anIsPointVisible ); + // Show/hide the point if necessary + updateTrsfPoint( aPointType ); } } //================================================================ -// Function : IsByTwoPoints +// Function : updateTrsfPoint +// Purpose : +//================================================================ +void HYDROGUI_PrsImage::updateTrsfPoint( const int thePointType ) +{ + // If image is transformed only by two points then the point C is invisible + bool anIsPointVisible = myIsTransformationPointPreview && ( + ( !myIsByTwoPoints ) || ( myIsByTwoPoints && ( thePointType != PointC ) ) ); + TransformationPoint& aTransformationPoint = myTransformationPointMap[ thePointType ]; + + double aRadius = 5; + const QPointF& aPoint = aTransformationPoint.Point; + QRectF aRect( aPoint - QPointF( aRadius, aRadius ), QSizeF( aRadius * 2 + 1, aRadius * 2 + 1 ) ); + aTransformationPoint.PointItem->setRect( aRect ); + aTransformationPoint.PointItem->setVisible( anIsPointVisible ); + + QPointF aCaptionShift( -aRadius * 2, aRadius * 2 ); + aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift ); + aTransformationPoint.CaptionItem->setVisible( anIsPointVisible ); +} + +//================================================================ +// Function : getIsByTwoPoints // Purpose : //================================================================ bool HYDROGUI_PrsImage::getIsByTwoPoints() const @@ -372,7 +381,7 @@ bool HYDROGUI_PrsImage::getIsByTwoPoints() const } //================================================================ -// Function : SetIsByTwoPoints +// Function : setIsByTwoPoints // Purpose : //================================================================ void HYDROGUI_PrsImage::setIsByTwoPoints( const bool theIsByTwoPoints ) @@ -380,8 +389,7 @@ void HYDROGUI_PrsImage::setIsByTwoPoints( const bool theIsByTwoPoints ) myIsByTwoPoints = theIsByTwoPoints; if ( myTransformationPointMap.contains( PointC ) ) { - TransformationPoint& aTransformationPoint = myTransformationPointMap[ PointC ]; - aTransformationPoint.PointItem->setVisible( myIsTransformationPointPreview && theIsByTwoPoints ); - aTransformationPoint.CaptionItem->setVisible( myIsTransformationPointPreview && theIsByTwoPoints ); + // Show/hide the point C if necessary + updateTrsfPoint( PointC ); } } diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.h b/src/HYDROGUI/HYDROGUI_PrsImage.h index 0287839c..f51ab35e 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.h +++ b/src/HYDROGUI/HYDROGUI_PrsImage.h @@ -91,6 +91,10 @@ public: protected: void computeTransformationPoints(); + /** + * Show/hide a transformation point if necessary. + */ + void updateTrsfPoint( const int thePointType ); protected: QCursor* getTransformationPointCursor() const { return myTransformationPointCursor; }