#include <qvalidator.h>
#include <qtabwidget.h>
+#include <vtkUnstructuredGrid.h>
#include <vtkDataSetMapper.h>
#include <vtkRenderer.h>
#include <vtkPlaneSource.h>
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 );
VisibilityOff();
PickableOff();
SetInfinitive(true);
+ SetOpacity(0.85);
SetMapper( myMapper );
}
~TPlane() {
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);
+ }
}
//=======================================================================
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;
}