Back to index

salome-geom  6.5.0
Public Member Functions | Private Slots | Private Member Functions | Private Attributes
OperationGUI_ClippingDlg Class Reference

#include <OperationGUI_ClippingDlg.h>

List of all members.

Public Member Functions

 OperationGUI_ClippingDlg (GeometryGUI *, QWidget *=0)
 ~OperationGUI_ClippingDlg ()

Private Slots

void ClickOnOk ()
bool ClickOnApply ()
void onActivate ()
void onReset ()

Private Member Functions

void Init ()
void enterEvent (QEvent *)

Private Attributes

ViewerTypes myViewerType
QGroupBox * GroupArguments
QLabel * TextLabelNear
SalomeApp_DoubleSpinBox * SpinBox_Near
QLabel * TextLabelFar
SalomeApp_DoubleSpinBox * SpinBox_Far
QPushButton * resetButton
QComboBox * TypeCB

Detailed Description

Definition at line 44 of file OperationGUI_ClippingDlg.h.


Constructor & Destructor Documentation

OperationGUI_ClippingDlg::OperationGUI_ClippingDlg ( GeometryGUI *  theGeometryGUI,
QWidget *  parent = 0 
)

Definition at line 58 of file OperationGUI_ClippingDlg.cxx.

  : GEOMBase_Skeleton( theGeometryGUI, parent, false )
{
  setWindowTitle( tr( "Change clipping range" ) );

  mainFrame()->GroupConstructors->setAttribute( Qt::WA_DeleteOnClose );
  mainFrame()->GroupConstructors->close();
  mainFrame()->GroupBoxName->setAttribute( Qt::WA_DeleteOnClose );
  mainFrame()->GroupBoxName->close();

  /***************************************************************/
  GroupArguments = new QGroupBox( centralWidget() );
  QGridLayout* GroupArgumentsLayout = new QGridLayout( GroupArguments );
  GroupArgumentsLayout->setSpacing( 6 );
  GroupArgumentsLayout->setMargin( 9 );

  // Controls
  TextLabelNear = new QLabel( tr( "Near" ), GroupArguments );
  GroupArgumentsLayout->addWidget( TextLabelNear, 0, 0 );

  SpinBox_Near = new SalomeApp_DoubleSpinBox( GroupArguments );
  initSpinBox( SpinBox_Near, COORD_MIN, COORD_MAX, 10.0, "length_precision" );
  GroupArgumentsLayout->addWidget( SpinBox_Near, 0, 1 );

  TextLabelFar = new QLabel( tr( "Far" ), GroupArguments );
  GroupArgumentsLayout->addWidget( TextLabelFar, 0, 2 );

  SpinBox_Far = new SalomeApp_DoubleSpinBox( GroupArguments );
  initSpinBox( SpinBox_Far, COORD_MIN, COORD_MAX, 10.0, "length_precision" );
  GroupArgumentsLayout->addWidget( SpinBox_Far, 0, 3 );

  resetButton  = new QPushButton( tr( "Reset" ), GroupArguments );
  GroupArgumentsLayout->addWidget( resetButton, 0, 4 );

  TypeCB = new QComboBox( GroupArguments );
  TypeCB->addItem( tr( "OFF" ) );
  TypeCB->addItem( tr( "BACK" ) );
  TypeCB->addItem( tr( "FRONT" ) );
  TypeCB->addItem( tr( "SLICE" ) );
  GroupArgumentsLayout->addWidget( TypeCB, 1, 0, 1, 5 );

  QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
  layout->setMargin( 0 ); layout->setSpacing( 6 );
  layout->addWidget( GroupArguments );

  /* signals and slots connections */
  connect( buttonOk(),    SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
  connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );

  connect( resetButton,   SIGNAL( clicked() ), this, SLOT( onReset() ) ) ;

  setHelpFileName( "none.htm" );

  Init();
}

Here is the call graph for this function:

Definition at line 118 of file OperationGUI_ClippingDlg.cxx.

{
  // no need to delete child widgets, Qt does it all for us
}

Member Function Documentation

bool OperationGUI_ClippingDlg::ClickOnApply ( ) [private, slot]

Definition at line 204 of file OperationGUI_ClippingDlg.cxx.

{
  SUIT_ViewWindow* anActiveWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
  if ( !anActiveWindow )
    return false;

  if ( anActiveWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
    SVTK_ViewWindow* aVTKFrame = dynamic_cast<SVTK_ViewWindow*>( anActiveWindow );
    if ( !aVTKFrame )
      return false;

    vtkRenderer* aRenderer = aVTKFrame->getRenderer();
    if ( !aRenderer ) return false;

    vtkCamera* anActiveCamera = aRenderer->GetActiveCamera();
    if ( anActiveCamera == NULL ) {
      return false;
    }

    vtkFloatingPointType range[2] = { SpinBox_Near->value(), SpinBox_Far->value() };
    if ( range[0] < 0.0 ) range[0] = 0.0;
    anActiveCamera->SetClippingRange( range );

    return true;
  }
  else if ( anActiveWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
    OCCViewer_ViewWindow* aOCCFrame = dynamic_cast<OCCViewer_ViewWindow*>( anActiveWindow );

    Handle(V3d_View) view3d = ( (OCCViewer_ViewPort3d*)aOCCFrame->getViewPort() )->getView();

    double depth = SpinBox_Near->value();
    double thickness = SpinBox_Far->value();
    int aType = TypeCB->currentIndex();

    view3d->SetZClippingType( V3d_TypeOfZclipping( aType ) );
    view3d->SetZClippingDepth( depth );
    view3d->SetZClippingWidth( thickness );
  }

  return true;
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OperationGUI_ClippingDlg::ClickOnOk ( ) [private, slot]

Definition at line 250 of file OperationGUI_ClippingDlg.cxx.

{
  setIsApplyAndClose( true );
  if ( ClickOnApply() )
    ClickOnCancel();
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OperationGUI_ClippingDlg::enterEvent ( QEvent *  ) [private]

Definition at line 270 of file OperationGUI_ClippingDlg.cxx.

{
  this->setEnabled( true );
}
void OperationGUI_ClippingDlg::Init ( ) [private]

Definition at line 127 of file OperationGUI_ClippingDlg.cxx.

{
  SUIT_ViewWindow* anActiveWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
  if ( !anActiveWindow )
    return;

  if ( anActiveWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
    SVTK_ViewWindow* aVTKFrame = dynamic_cast<SVTK_ViewWindow*>( anActiveWindow );
    if ( !aVTKFrame )
      return;

    TextLabelNear->setText( tr( "Near" ) );
    TextLabelFar->setText( tr( "Far" ) );

    TypeCB->hide();

    vtkRenderer* aRenderer = aVTKFrame->getRenderer();
    if ( !aRenderer ) return;

    vtkCamera* anActiveCamera = aRenderer->GetActiveCamera();
    if ( anActiveCamera == NULL ) {
      return;
    }

      // Find the plane equation for the camera view plane
    double vn[3];
    anActiveCamera->GetViewPlaneNormal( vn );
    double  position[3];
    anActiveCamera->GetPosition( position );

    vtkFloatingPointType bounds[6];
    aRenderer->ComputeVisiblePropBounds( bounds );

    double center[3];
    center[0] = ( bounds[0] + bounds[1] ) / 2.0;
    center[1] = ( bounds[2] + bounds[3] ) / 2.0;
    center[2] = ( bounds[4] + bounds[5] ) / 2.0;

    double width = sqrt( ( bounds[1]-bounds[0] ) * ( bounds[1]-bounds[0] ) +
                         ( bounds[3]-bounds[2] ) * ( bounds[3]-bounds[2] ) +
                         ( bounds[5]-bounds[4] ) * ( bounds[5]-bounds[4] ) );

    double distance = sqrt( ( position[0]-center[0] ) * ( position[0]-center[0] ) +
                            ( position[1]-center[1] ) * ( position[1]-center[1] ) +
                            ( position[2]-center[2] ) * ( position[2]-center[2] ) );

    vtkFloatingPointType range[2] = { distance - width/2.0, distance + width/2.0 };

    SpinBox_Near->setValue( range[0] );
    SpinBox_Far->setValue( range[1] );

    return;
  }
  else if ( anActiveWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
    OCCViewer_ViewWindow* aOCCFrame = dynamic_cast<OCCViewer_ViewWindow*>( anActiveWindow );

    TextLabelNear->setText( tr( "Depth" ) );
    TextLabelFar->setText( tr( "Thickness" ) );

    Handle(V3d_View) view3d = ( (OCCViewer_ViewPort3d*)aOCCFrame->getViewPort() )->getView();

    double depth, thickness;
    int ztype = view3d->ZClipping( depth, thickness );
    SpinBox_Near->setValue( depth );
    SpinBox_Far->setValue( thickness );
    TypeCB->setCurrentIndex( ztype );

    //Handle(V3d_Plane) aPlane = new V3d_Plane( aOCCFrame->getViewer()->getViewer3d() ,0, 0, 1, -100);
    //aPlane->Display(view3d);
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:

void OperationGUI_ClippingDlg::onActivate ( ) [private, slot]

Definition at line 261 of file OperationGUI_ClippingDlg.cxx.

{
  GEOMBase_Skeleton::ActivateThisDialog();
}
void OperationGUI_ClippingDlg::onReset ( ) [private, slot]

Definition at line 279 of file OperationGUI_ClippingDlg.cxx.

{
  SUIT_ViewWindow* anActiveWindow =
    SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
  if ( !anActiveWindow )
    return;

  if ( anActiveWindow->getViewManager()->getType() == SVTK_Viewer::Type() ) {
    SVTK_ViewWindow* aVTKFrame = dynamic_cast<SVTK_ViewWindow*>( anActiveWindow );
    if ( !aVTKFrame )
      return;

    vtkRenderer* aRenderer = aVTKFrame->getRenderer();
    if ( !aRenderer ) return;

    vtkCamera* anActiveCamera = aRenderer->GetActiveCamera();
    if ( anActiveCamera == NULL ) {
      return;
    }

      // Find the plane equation for the camera view plane
    double vn[3];
    anActiveCamera->GetViewPlaneNormal( vn );
    double  position[3];
    anActiveCamera->GetPosition( position );

    vtkFloatingPointType bounds[6];
    aRenderer->ComputeVisiblePropBounds( bounds );

    double center[3];
    center[0] = ( bounds[0] + bounds[1] ) / 2.0;
    center[1] = ( bounds[2] + bounds[3] ) / 2.0;
    center[2] = ( bounds[4] + bounds[5] ) / 2.0;

    double width = sqrt( ( bounds[1]-bounds[0] ) * ( bounds[1]-bounds[0] ) +
                         ( bounds[3]-bounds[2] ) * ( bounds[3]-bounds[2] ) +
                         ( bounds[5]-bounds[4] ) * ( bounds[5]-bounds[4] ) );

    double distance = sqrt( ( position[0]-center[0] ) * ( position[0]-center[0] ) +
                            ( position[1]-center[1] ) * ( position[1]-center[1] ) +
                            ( position[2]-center[2] ) * ( position[2]-center[2] ) );

    vtkFloatingPointType range[2] = { distance - width/2.0, distance + width/2.0 };

    SpinBox_Near->setValue( range[0] );
    SpinBox_Far->setValue( range[1] );

    return;
  }
  else if ( anActiveWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() ) {
    OCCViewer_ViewWindow* aOCCFrame = dynamic_cast<OCCViewer_ViewWindow*>( anActiveWindow );

    TextLabelNear->setText( tr( "Depth"  ) );
    TextLabelFar->setText( tr( "Thickness"  ) );

    Handle(V3d_View) view3d = ( (OCCViewer_ViewPort3d*)aOCCFrame->getViewPort() )->getView();

    view3d->SetZClippingType( V3d_TypeOfZclipping( 0 ) );
    view3d->ZFitAll();
    double depth, thickness;
    int ztype= view3d->ZClipping( depth, thickness );
    SpinBox_Near->setValue( 0 );
    SpinBox_Far->setValue( 1000 );
    TypeCB->setCurrentIndex( ztype );
  }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Member Data Documentation

Definition at line 60 of file OperationGUI_ClippingDlg.h.

Definition at line 58 of file OperationGUI_ClippingDlg.h.

QPushButton* OperationGUI_ClippingDlg::resetButton [private]

Definition at line 65 of file OperationGUI_ClippingDlg.h.

SalomeApp_DoubleSpinBox* OperationGUI_ClippingDlg::SpinBox_Far [private]

Definition at line 64 of file OperationGUI_ClippingDlg.h.

SalomeApp_DoubleSpinBox* OperationGUI_ClippingDlg::SpinBox_Near [private]

Definition at line 62 of file OperationGUI_ClippingDlg.h.

Definition at line 63 of file OperationGUI_ClippingDlg.h.

Definition at line 61 of file OperationGUI_ClippingDlg.h.

QComboBox* OperationGUI_ClippingDlg::TypeCB [private]

Definition at line 66 of file OperationGUI_ClippingDlg.h.


The documentation for this class was generated from the following files: