From: rkv Date: Wed, 13 Nov 2013 07:56:08 +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~12 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=844c6abc897469c996e8df5a1569c3aeaa08c446;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 eaba5358..1d9510f4 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.cxx @@ -288,6 +288,8 @@ 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 ) ) ); + aTransformLayout->setColumnStretch( 1, 1 ); // double aTransformLayout->setColumnStretch( 3, 1 ); // degrees aTransformLayout->setColumnStretch( 5, 1 ); // minutes diff --git a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h index 8018366b..59de8c6c 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageDlg.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageDlg.h @@ -138,6 +138,7 @@ signals: int theValue ); void modeActivated( int ); void refImageActivated( const QString& ); + void setIsByTwoPoints( 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 d3a82f89..82de7403 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.cxx @@ -217,6 +217,7 @@ void HYDROGUI_ImportImageOp::setPresentationTrsfPoints( HYDROGUI_PrsImage* thePr if ( !theIsByTwoPoints ) aPointMap[ HYDROGUI_PrsImage::PointC ].Point = theLocalPointC; + thePrs->setIsByTwoPoints( theIsByTwoPoints ); thePrs->setTransformationPointMap( aPointMap ); } } @@ -262,19 +263,29 @@ void HYDROGUI_ImportImageOp::commitOperation() HYDROGUI_InputPanel* HYDROGUI_ImportImageOp::createInputPanel() const { HYDROGUI_InputPanel* aPanel = new HYDROGUI_ImportImageDlg( module(), getName() ); - connect( aPanel, SIGNAL( createPreview( QImage ) ), - this, SLOT( onCreatePreview( QImage ) ) ); - connect( aPanel, SIGNAL( activatePointSelection( int ) ), - this, SLOT( onActivatePointSelection( int ) ) ); - connect( aPanel, SIGNAL( pointCoordChanged( bool, int, bool, int ) ), - this, SLOT( onPointCoordChanged( bool, int, bool, int ) ) ); - connect( aPanel, SIGNAL( modeActivated( int ) ), - this, SLOT( onModeActivated( int ) ) ); + connect( aPanel, SIGNAL( createPreview( QImage ) ), SLOT( onCreatePreview( QImage ) ) ); + connect( aPanel, SIGNAL( activatePointSelection( int ) ), SLOT( onActivatePointSelection( int ) ) ); + connect( aPanel, SIGNAL( pointCoordChanged( bool, int, bool, int ) ), + SLOT( onPointCoordChanged( bool, int, bool, int ) ) ); + connect( aPanel, SIGNAL( modeActivated( int ) ), SLOT( onModeActivated( int ) ) ); connect( aPanel, SIGNAL( refImageActivated( const QString& ) ), - this, SLOT( onRefImageActivated( const QString& ) ) ); + SLOT( onRefImageActivated( const QString& ) ) ); + connect( aPanel, SIGNAL( setIsByTwoPoints( bool ) ), SLOT( onSetIsByTwoPoints( bool ) ) ); return aPanel; } +void HYDROGUI_ImportImageOp::onSetIsByTwoPoints( bool theIsSetByTwoPoints ) +{ + if ( myPreviewPrs ) + { + myPreviewPrs->setIsByTwoPoints( theIsSetByTwoPoints ); + } + if ( myRefPreviewPrs ) + { + myRefPreviewPrs->setIsByTwoPoints( theIsSetByTwoPoints ); + } +} + bool HYDROGUI_ImportImageOp::checkPoints( const QPointF& thePointA, const QPointF& thePointB, const QPointF& thePointC, diff --git a/src/HYDROGUI/HYDROGUI_ImportImageOp.h b/src/HYDROGUI/HYDROGUI_ImportImageOp.h index e4733731..ade48517 100644 --- a/src/HYDROGUI/HYDROGUI_ImportImageOp.h +++ b/src/HYDROGUI/HYDROGUI_ImportImageOp.h @@ -57,6 +57,7 @@ protected slots: void onPointCoordChanged( bool, int, bool, int ); void onModeActivated( int ); void onRefImageActivated( const QString& ); + void onSetIsByTwoPoints( bool theIsSetByTwoPoints ); void onLastViewClosed( SUIT_ViewManager* ); diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.cxx b/src/HYDROGUI/HYDROGUI_PrsImage.cxx index 9e7be142..250d4c85 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.cxx +++ b/src/HYDROGUI/HYDROGUI_PrsImage.cxx @@ -342,18 +342,46 @@ 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( anIsVisible ); + aTransformationPoint.PointItem->setVisible( anIsPointVisible ); QPointF aCaptionShift( -aRadius * 2, aRadius * 2 ); aTransformationPoint.CaptionItem->setPos( aPoint + aCaptionShift ); - aTransformationPoint.CaptionItem->setVisible( anIsVisible ); + aTransformationPoint.CaptionItem->setVisible( anIsPointVisible ); + } +} + +//================================================================ +// Function : IsByTwoPoints +// Purpose : +//================================================================ +bool HYDROGUI_PrsImage::getIsByTwoPoints() const +{ + return myIsByTwoPoints; +} + +//================================================================ +// Function : SetIsByTwoPoints +// Purpose : +//================================================================ +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 ); } } diff --git a/src/HYDROGUI/HYDROGUI_PrsImage.h b/src/HYDROGUI/HYDROGUI_PrsImage.h index c5d57981..0287839c 100644 --- a/src/HYDROGUI/HYDROGUI_PrsImage.h +++ b/src/HYDROGUI/HYDROGUI_PrsImage.h @@ -59,6 +59,9 @@ public: void setIsTransformationPointPreview( const bool theState ); bool getIsTransformationPointPreview() const; + void setIsByTwoPoints( const bool theIsByTwoPoints ); + bool getIsByTwoPoints() const; + void setTransformationPointType( const int thePointType ); void setTransformationPointMap( const TransformationPointMap& theMap ); @@ -100,6 +103,7 @@ protected: HYDROGUI_PrsImageFrame* myPrsImageFrame; bool myIsTransformationPointPreview; + bool myIsByTwoPoints; int myTransformationPointType; TransformationPointMap myTransformationPointMap;