From 3b07092d7b902c4194b061290bd9db16a3416158 Mon Sep 17 00:00:00 2001 From: mpa Date: Thu, 5 Feb 2015 12:40:52 +0300 Subject: [PATCH] INT PAL 0052613: Creation of clipping plane with absolute mode is incorrect --- src/OCCViewer/OCCViewer_ClipPlane.cxx | 7 +- src/OCCViewer/OCCViewer_ClippingDlg.cxx | 88 +++++++++++++------------ 2 files changed, 51 insertions(+), 44 deletions(-) diff --git a/src/OCCViewer/OCCViewer_ClipPlane.cxx b/src/OCCViewer/OCCViewer_ClipPlane.cxx index 8584ddcb0..5a57eeb74 100644 --- a/src/OCCViewer/OCCViewer_ClipPlane.cxx +++ b/src/OCCViewer/OCCViewer_ClipPlane.cxx @@ -117,9 +117,10 @@ void OCCViewer_ClipPlane::OrientationToXYZ( double &theDx, double &theDy, double break; case AbsoluteCustom : - theDx = AbsoluteOrientation.Dx; - theDy = AbsoluteOrientation.Dy; - theDz = AbsoluteOrientation.Dz; + int anInvertCoeff = AbsoluteOrientation.IsInvert ? 1 : -1; + theDx = anInvertCoeff * AbsoluteOrientation.Dx; + theDy = anInvertCoeff * AbsoluteOrientation.Dy; + theDz = anInvertCoeff * AbsoluteOrientation.Dz; break; } diff --git a/src/OCCViewer/OCCViewer_ClippingDlg.cxx b/src/OCCViewer/OCCViewer_ClippingDlg.cxx index 2c993287b..a1792961b 100644 --- a/src/OCCViewer/OCCViewer_ClippingDlg.cxx +++ b/src/OCCViewer/OCCViewer_ClippingDlg.cxx @@ -744,6 +744,7 @@ void OCCViewer_ClippingDlg::setPlaneParam( OCCViewer_ClipPlane& thePlane ) thePlane.AbsoluteOrientation.Dx = SpinBox_Dx->value(); thePlane.AbsoluteOrientation.Dy = SpinBox_Dy->value(); thePlane.AbsoluteOrientation.Dz = SpinBox_Dz->value(); + thePlane.AbsoluteOrientation.IsInvert = false; } else { @@ -1261,6 +1262,7 @@ void OCCViewer_ClippingDlg::onReset() SpinBox_Z->setValue(0); myBusy = false; + SetCurrentPlaneParam(); updateClipping(); } @@ -1311,47 +1313,50 @@ void OCCViewer_ClippingDlg::onOrientationAbsoluteChanged( int mode ) SpinBox_Dy->setEnabled( isUserMode ); SpinBox_Dz->setEnabled( isUserMode ); - if ( !isUserMode ) { - - double aDx = 0, aDy = 0, aDz = 0; + int aCurPlaneIndex = ComboBoxPlanes->currentIndex(); + OCCViewer_ClipPlane& aPlane = getClipPlane( aCurPlaneIndex ); + double aDx = 0, aDy = 0, aDz = 0; - if ( mode == 1 ) - { - aDz = 1; - TextLabelZ->setEnabled( true ); - SpinBox_Z->setEnabled( true ); - SpinBox_Z->setFocus(); - } - else if ( mode == 2 ) - { - aDx = 1; - TextLabelX->setEnabled( true ); - SpinBox_X->setEnabled( true ); - SpinBox_X->setFocus(); - } - else if ( mode == 3 ) - { - aDy = 1; - TextLabelY->setEnabled( true ); - SpinBox_Y->setEnabled( true ); - SpinBox_Y->setFocus(); - } - - int aCurPlaneIndex = ComboBoxPlanes->currentIndex(); - OCCViewer_ClipPlane& aPlane = getClipPlane( aCurPlaneIndex ); - if ( aPlane.AbsoluteOrientation.IsInvert == true ) - { - aDx = -aDx; - aDy = -aDy; - aDz = -aDz; - } + if ( mode == 0 ) + { + aDx = aPlane.AbsoluteOrientation.Dx; + aDy = aPlane.AbsoluteOrientation.Dy; + aDz = aPlane.AbsoluteOrientation.Dz; + } + else if ( mode == 1 ) + { + aDz = 1; + TextLabelZ->setEnabled( true ); + SpinBox_Z->setEnabled( true ); + SpinBox_Z->setFocus(); + } + else if ( mode == 2 ) + { + aDx = 1; + TextLabelX->setEnabled( true ); + SpinBox_X->setEnabled( true ); + SpinBox_X->setFocus(); + } + else if ( mode == 3 ) + { + aDy = 1; + TextLabelY->setEnabled( true ); + SpinBox_Y->setEnabled( true ); + SpinBox_Y->setFocus(); + } - myBusy = true; - SpinBox_Dx->setValue( aDx ); - SpinBox_Dy->setValue( aDy ); - SpinBox_Dz->setValue( aDz ); - myBusy = false; + if ( aPlane.AbsoluteOrientation.IsInvert == true ) + { + aDx = -aDx; + aDy = -aDy; + aDz = -aDz; } + + myBusy = true; + SpinBox_Dx->setValue( aDx ); + SpinBox_Dy->setValue( aDy ); + SpinBox_Dz->setValue( aDz ); + myBusy = false; if ( !myIsUpdatingControls ) { @@ -1478,9 +1483,10 @@ void OCCViewer_ClippingDlg::onPlaneDragged( const Handle(AIS_Plane)& thePlane ) { if ( aClipPlane.OrientationType == OCCViewer_ClipPlane::AbsoluteCustom ) { - aClipPlane.AbsoluteOrientation.Dx = aPlaneN.X(); - aClipPlane.AbsoluteOrientation.Dy = aPlaneN.Y(); - aClipPlane.AbsoluteOrientation.Dz = aPlaneN.Z(); + int anInvertCoeff = aClipPlane.AbsoluteOrientation.IsInvert ? 1 : -1; + aClipPlane.AbsoluteOrientation.Dx = anInvertCoeff * aPlaneN.X(); + aClipPlane.AbsoluteOrientation.Dy = anInvertCoeff * aPlaneN.Y(); + aClipPlane.AbsoluteOrientation.Dz = anInvertCoeff * aPlaneN.Z(); } } else -- 2.39.2