From 476c241f3a87fb4d824e540aa26efb02778e5c6c Mon Sep 17 00:00:00 2001 From: eap Date: Thu, 26 May 2005 06:47:33 +0000 Subject: [PATCH] IPAL8896. Make a preview transparen, propertional to mesh size, visible if no actors yet created, remove it at dlg closure. --- src/VISUGUI/VisuGUI_Plot3DDlg.cxx | 63 ++++++++++++++++++------------- 1 file changed, 37 insertions(+), 26 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx index 61a3df73..f6d99331 100644 --- a/src/VISUGUI/VisuGUI_Plot3DDlg.cxx +++ b/src/VISUGUI/VisuGUI_Plot3DDlg.cxx @@ -40,6 +40,7 @@ #include #include +#include #include #include #include @@ -75,21 +76,24 @@ static void renderViewFrame(QAD_Study* theStudy) class TPlane : public SALOME_Actor { + float mySize; vtkDataSetMapper* myMapper; vtkPlaneSource* myPlaneSource; public: // constructor - TPlane() { + TPlane(float planeSize): mySize( planeSize ) + { Init(); } // set plane parameters - void Set(float origin[3], float normal[3]) { + void Set(float origin[3], float normal[3]) + { float point2[3], point1[3]; vtkMath::Perpendiculars( normal, point1, point2, 0. ); for ( int i = 0; i < 3; ++i ) { - point1[ i ] += origin[ i ]; - point2[ i ] += origin[ i ]; + point1[ i ] = point1[ i ] * mySize + origin[ i ]; + point2[ i ] = point2[ i ] * mySize + origin[ i ]; } myPlaneSource->SetOrigin( origin ); myPlaneSource->SetPoint1( point1 ); @@ -107,6 +111,7 @@ class TPlane : public SALOME_Actor VisibilityOff(); PickableOff(); SetInfinitive(true); + SetOpacity(0.85); SetMapper( myMapper ); } ~TPlane() { @@ -362,34 +367,35 @@ void VisuGUI_Plot3DPane::onPrsType( int id ) void VisuGUI_Plot3DPane::updatePreview() { - if ( myInitFromPrs ) + if ( myInitFromPrs || !myPrs || !myViewFrame ) return; - if ( PreviewChkB->isChecked() ) // show preview plane + bool fitall = false; + if ( PreviewChkB->isChecked() ) // place preview plane { + // get plane preview actor TPlane* planePreview = (TPlane*) myPreviewActor; if ( !planePreview ) { - myPreviewActor = planePreview = new TPlane; - if ( myViewFrame ) { - myViewFrame->AddActor( planePreview ); - if ( !VisuGUI::GetActor( myPrs )) - myViewFrame->onViewFitAll(); - } + myPreviewActor = planePreview = new TPlane( myPrs->GetInput()->GetLength() ); + myViewFrame->AddActor( planePreview ); + fitall = !VisuGUI::GetActor( myPrs ); } - if ( myPrs ) // set plane parameters corresponding to control values - { - storePrsParams(); - float normal[3], origin[3]; - myPrs->GetPlot3DPL()->GetBasePlane( origin, normal, true ); - planePreview->Set( origin, normal ); - planePreview->SetVisibility( true ); - restorePrsParams(); - } - } - else if ( myPreviewActor ) // erase preview - { - myPreviewActor->SetVisibility( false ); + // set plane parameters corresponding to control values + storePrsParams(); + float normal[3], origin[3]; + myPrs->GetPlot3DPL()->GetBasePlane( origin, normal, true ); + planePreview->Set( origin, normal ); + restorePrsParams(); } + if ( myPreviewActor ) + myPreviewActor->SetVisibility( PreviewChkB->isChecked() ); + renderViewFrame( myStudyFrame->getStudy() ); + + if ( fitall ) { + myPreviewActor->SetInfinitive(false); + myViewFrame->onViewFitAll(); + myPreviewActor->SetInfinitive(true); + } } //======================================================================= @@ -491,8 +497,13 @@ int VisuGUI_Plot3DPane::storeToPrsObject(VISU::Plot3D_i* thePrs) bool VisuGUI_Plot3DPane::check() { - if ( myPreviewActor ) // erase preview + if ( myPreviewActor && myViewFrame) // erase preview + { myPreviewActor->SetVisibility( false ); + myViewFrame->RemoveActor(myPreviewActor); + myPreviewActor->Delete(); + myPreviewActor = 0; + } return true; } -- 2.39.2