+ MenuMode = new QMenu( "MenuMode", buttonNew );
+ MenuMode->addAction( tr( "ABSOLUTE" ), this, SLOT( onModeAbsolute() ) );
+ MenuMode->addAction( tr( "RELATIVE" ), this, SLOT( onModeRelative() ) );
+ buttonNew->setMenu( MenuMode );
+ CurrentMode = SMESH::Absolute;
+
+ buttonDelete = new QPushButton(tr("SMESH_BUT_DELETE"), GroupPlanes);
+
+ QLabel* aLabel = new QLabel(tr("MESHES_SUBMESHES_GROUPS"), GroupPlanes);
+
+ ActorList = new QListWidget(GroupPlanes);
+ ActorList->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ SelectAllCheckBox = new QCheckBox(tr("SELECT_ALL"), GroupPlanes);
+
+ GroupPlanesLayout->addWidget(ComboBoxPlanes, 0, 0);
+ GroupPlanesLayout->addWidget(isOpenGLClipping, 0, 1);
+ GroupPlanesLayout->addWidget(new QWidget(), 0, 2);
+ GroupPlanesLayout->addWidget(buttonNew, 0, 3);
+ GroupPlanesLayout->addWidget(buttonDelete, 0, 4);
+ GroupPlanesLayout->addWidget(aLabel, 1, 0, 1, 5);
+ GroupPlanesLayout->addWidget(ActorList, 2, 0, 1, 5);
+ GroupPlanesLayout->addWidget(SelectAllCheckBox, 3, 0, 1, 5);
+ GroupPlanesLayout->setColumnStretch( 1, 1 );
+
+ ModeStackedLayout = new QStackedLayout();
+
+ // Controls for defining plane parameters
+ /********************** Mode Absolute **********************/
+ /* Controls for absolute mode of clipping plane:
+ X, Y, Z - coordinates of the intersection of cutting plane and the three axes
+ Dx, Dy, Dz - components of normal to the cutting plane
+ Orientation - direction of cutting plane
+ */
+ const double min = -1e+7;
+ const double max = 1e+7;
+ const double step = 5;
+ const int precision = -7;
+
+ // Croup Point
+ QGroupBox* GroupAbsolutePoint = new QGroupBox( this );
+ GroupAbsolutePoint->setObjectName( "GroupPoint" );
+ GroupAbsolutePoint->setTitle( tr("BASE_POINT") );
+ QGridLayout* GroupPointLayout = new QGridLayout( GroupAbsolutePoint );
+ GroupPointLayout->setAlignment( Qt::AlignTop );
+ GroupPointLayout->setSpacing( 6 ); GroupPointLayout->setMargin( 11 );
+
+ TextLabelX = new QLabel( GroupAbsolutePoint );
+ TextLabelX->setObjectName( "TextLabelX" );
+ TextLabelX->setText( tr("X:") );
+ GroupPointLayout->addWidget( TextLabelX, 0, 0 );
+
+ SpinBox_X = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );
+ SpinBox_X->setObjectName("SpinBox_X" );
+ SpinBox_X->setPrecision( precision );
+ GroupPointLayout->addWidget( SpinBox_X, 0, 1 );
+
+ TextLabelY = new QLabel( GroupAbsolutePoint );
+ TextLabelY->setObjectName( "TextLabelY" );
+ TextLabelY->setText( tr("Y:") );
+ GroupPointLayout->addWidget( TextLabelY, 0, 2 );
+
+ SpinBox_Y = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );
+ SpinBox_Y->setObjectName("SpinBox_Y" );
+ SpinBox_Y->setPrecision( precision );
+ GroupPointLayout->addWidget( SpinBox_Y, 0, 3 );
+
+ TextLabelZ = new QLabel( GroupAbsolutePoint );
+ TextLabelZ->setObjectName( "TextLabelZ" );
+ TextLabelZ->setText( tr("Z:") );
+ GroupPointLayout->addWidget( TextLabelZ, 0, 4 );
+
+ SpinBox_Z = new QtxDoubleSpinBox( min, max, step, GroupAbsolutePoint );
+ SpinBox_Z->setObjectName("SpinBox_Z" );
+ SpinBox_Z->setPrecision( precision );
+ GroupPointLayout->addWidget( SpinBox_Z, 0, 5 );
+
+ resetButton = new QPushButton( GroupAbsolutePoint );
+ resetButton->setObjectName( "resetButton" );
+ resetButton->setText( tr( "RESET" ) );
+ GroupPointLayout->addWidget( resetButton, 0, 6 );
+
+ // Group Direction
+ GroupAbsoluteDirection = new QGroupBox( this );
+ GroupAbsoluteDirection->setObjectName( "GroupDirection" );
+ GroupAbsoluteDirection->setTitle( tr("DIRECTION") );
+ QGridLayout* GroupDirectionLayout = new QGridLayout( GroupAbsoluteDirection );
+ GroupDirectionLayout->setAlignment( Qt::AlignTop );
+ GroupDirectionLayout->setSpacing( 6 );
+ GroupDirectionLayout->setMargin( 11 );
+
+ TextLabelDx = new QLabel( GroupAbsoluteDirection );
+ TextLabelDx->setObjectName( "TextLabelDx" );
+ TextLabelDx->setText( tr("Dx:") );
+ GroupDirectionLayout->addWidget( TextLabelDx, 0, 0 );
+
+ SpinBox_Dx = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );
+ SpinBox_Dx->setObjectName("SpinBox_Dx" );
+ SpinBox_Dx->setPrecision( precision );
+ GroupDirectionLayout->addWidget( SpinBox_Dx, 0, 1 );
+
+ TextLabelDy = new QLabel( GroupAbsoluteDirection );
+ TextLabelDy->setObjectName( "TextLabelDy" );
+ TextLabelDy->setText( tr("Dy:") );
+ GroupDirectionLayout->addWidget( TextLabelDy, 0, 2 );
+
+ SpinBox_Dy = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );
+ SpinBox_Dy->setObjectName("SpinBox_Dy" );
+ SpinBox_Dy->setPrecision( precision );
+ GroupDirectionLayout->addWidget( SpinBox_Dy, 0, 3 );
+
+ TextLabelDz = new QLabel( GroupAbsoluteDirection );
+ TextLabelDz->setObjectName( "TextLabelDz" );
+ TextLabelDz->setText( tr("Dz:") );
+ GroupDirectionLayout->addWidget( TextLabelDz, 0, 4 );
+
+ SpinBox_Dz = new QtxDoubleSpinBox( min, max, step, GroupAbsoluteDirection );
+ SpinBox_Dz->setObjectName("SpinBox_Dz" );
+ SpinBox_Dz->setPrecision( precision );
+ GroupDirectionLayout->addWidget( SpinBox_Dz, 0, 5 );
+
+ invertButton = new QPushButton( GroupAbsoluteDirection );
+ invertButton->setObjectName( "invertButton" );
+ invertButton->setText( tr( "INVERT" ) );
+ GroupDirectionLayout->addWidget( invertButton, 0, 6 );
+
+ CBAbsoluteOrientation = new QComboBox( GroupAbsoluteDirection );
+ CBAbsoluteOrientation->setObjectName( "AbsoluteOrientation" );
+ CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "CUSTOM" ) );
+ CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||X-Y" ) );
+ CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||Y-Z" ) );
+ CBAbsoluteOrientation->insertItem( CBAbsoluteOrientation->count(), tr( "||Z-X" ) );
+ GroupDirectionLayout->addWidget( CBAbsoluteOrientation, 1, 0, 1, 6 );
+
+ QVBoxLayout* ModeActiveLayout = new QVBoxLayout();
+ ModeActiveLayout->setMargin( 11 ); ModeActiveLayout->setSpacing( 6 );
+ ModeActiveLayout->addWidget( GroupAbsolutePoint );
+ ModeActiveLayout->addWidget( GroupAbsoluteDirection );
+
+ QWidget* ModeActiveWidget = new QWidget( this );
+ ModeActiveWidget->setLayout( ModeActiveLayout );
+
+ /********************** Mode Relative **********************/
+ /* Controls for relative mode of clipping plane:
+ Distance - Value from 0 to 1.
+ Specifies the distance from the minimum value in a given direction of bounding box to the current position
+ Rotation1, Rotation2 - turn angles of cutting plane in given directions
+ Orientation - direction of cutting plane
+ */
+ QGroupBox* GroupParameters = new QGroupBox( tr("SMESH_PARAMETERS"), this );
+ QGridLayout* GroupParametersLayout = new QGridLayout( GroupParameters );
+ GroupParametersLayout->setMargin( 11 ); GroupParametersLayout->setSpacing( 6 );
+
+ TextLabelOrientation = new QLabel( tr("SMESH_ORIENTATION"), GroupParameters);
+ TextLabelOrientation->setObjectName( "TextLabelOrientation" );
+ GroupParametersLayout->addWidget( TextLabelOrientation, 0, 0 );
+
+ CBRelativeOrientation = new QComboBox(GroupParameters);
+ CBRelativeOrientation->setObjectName( "RelativeOrientation" );
+ CBRelativeOrientation->addItem( tr("ALONG_XY") );
+ CBRelativeOrientation->addItem( tr("ALONG_YZ") );
+ CBRelativeOrientation->addItem( tr("ALONG_ZX") );
+ GroupParametersLayout->addWidget( CBRelativeOrientation, 0, 1 );
+
+ TLValueDistance = new QLabel( GroupParameters );
+ TLValueDistance->setObjectName( "TLValueDistance" );
+ TLValueDistance->setAlignment( Qt::AlignCenter );
+ TLValueDistance->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ QFont fnt = TLValueDistance->font(); fnt.setBold( true ); TLValueDistance->setFont( fnt );
+ GroupParametersLayout->addWidget( TLValueDistance, 1, 1 );
+
+ TextLabelDistance = new QLabel( tr("SMESH_DISTANCE"), GroupParameters );
+ TextLabelDistance->setObjectName( "TextLabelDistance" );
+ GroupParametersLayout->addWidget( TextLabelDistance, 2, 0 );
+
+ SliderDistance = new QSlider( Qt::Horizontal, GroupParameters );
+ SliderDistance->setObjectName( "SliderDistance" );
+ SliderDistance->setMinimumSize( 300, 0 );
+ SliderDistance->setMinimum( 0 );
+ SliderDistance->setMaximum( 100 );
+ SliderDistance->setSingleStep( 1 );
+ SliderDistance->setPageStep( 10 );
+ SliderDistance->setTracking( false );
+ GroupParametersLayout->addWidget( SliderDistance, 2, 1 );
+
+ TLValueRotation1 = new QLabel( GroupParameters );
+ TLValueRotation1->setObjectName( "TLValueRotation1" );
+ TLValueRotation1->setAlignment( Qt::AlignCenter );
+ TLValueRotation1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ TLValueRotation1->setFont( fnt );
+ GroupParametersLayout->addWidget( TLValueRotation1, 3, 1 );
+
+ TextLabelRotation1 = new QLabel( tr("ROTATION_AROUND_X_Y2Z"), GroupParameters );
+ TextLabelRotation1->setObjectName( "TextLabelRotation1" );
+ GroupParametersLayout->addWidget( TextLabelRotation1, 4, 0 );
+
+ SliderRotation1 = new QSlider( Qt::Horizontal, GroupParameters );
+ SliderRotation1->setObjectName( "SliderRotation1" );
+ SliderRotation1->setMinimumSize( 300, 0 );
+ SliderRotation1->setMinimum( -180 );
+ SliderRotation1->setMaximum( 180 );
+ SliderRotation1->setSingleStep( 1 );
+ SliderRotation1->setPageStep( 10 );
+ SliderRotation1->setTracking(false);
+ GroupParametersLayout->addWidget( SliderRotation1, 4, 1 );
+
+ TLValueRotation2 = new QLabel( GroupParameters );
+ TLValueRotation2->setObjectName( "TLValueRotation2" );
+ TLValueRotation2->setAlignment( Qt::AlignCenter );
+ TLValueRotation2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+ TLValueRotation2->setFont( fnt );
+ GroupParametersLayout->addWidget( TLValueRotation2, 5, 1 );
+
+ TextLabelRotation2 = new QLabel(tr("ROTATION_AROUND_Y_X2Z"), GroupParameters);
+ TextLabelRotation2->setObjectName( "TextLabelRotation2" );
+ TextLabelRotation2->setObjectName( "TextLabelRotation2" );
+ GroupParametersLayout->addWidget( TextLabelRotation2, 6, 0 );
+
+ SliderRotation2 = new QSlider( Qt::Horizontal, GroupParameters );
+ SliderRotation2->setObjectName( "SliderRotation2" );
+ SliderRotation2->setMinimumSize( 300, 0 );
+ SliderRotation2->setMinimum( -180 );
+ SliderRotation2->setMaximum( 180 );
+ SliderRotation2->setSingleStep( 1 );
+ SliderRotation2->setPageStep( 10 );
+ SliderRotation2->setTracking(false);
+ GroupParametersLayout->addWidget( SliderRotation2, 6, 1 );
+
+ /***************************************************************/
+ QWidget* CheckBoxWidget = new QWidget( this );
+ QHBoxLayout* CheckBoxLayout = new QHBoxLayout( CheckBoxWidget );
+
+ PreviewCheckBox = new QCheckBox( tr("SHOW_PREVIEW"), CheckBoxWidget );
+ PreviewCheckBox->setObjectName( "PreviewCheckBox" );
+ PreviewCheckBox->setChecked( true );
+ CheckBoxLayout->addWidget( PreviewCheckBox, 0, Qt::AlignCenter );
+
+ AutoApplyCheckBox = new QCheckBox( tr("AUTO_APPLY"), CheckBoxWidget );
+ AutoApplyCheckBox->setObjectName( "AutoApplyCheckBox" );
+ CheckBoxLayout->addWidget( AutoApplyCheckBox, 0, Qt::AlignCenter );
+
+ /***************************************************************/
+ // Controls for "Ok", "Apply" and "Close" button
+ QGroupBox* GroupButtons = new QGroupBox(this);
+ QHBoxLayout* GroupButtonsLayout = new QHBoxLayout(GroupButtons);
+ GroupButtonsLayout->setSpacing(SPACING);
+ GroupButtonsLayout->setMargin(MARGIN);
+
+ buttonOk = new QPushButton( tr( "SMESH_BUT_APPLY_AND_CLOSE" ), GroupButtons );
+ buttonOk->setAutoDefault( true );
+ buttonOk->setDefault( true );
+ buttonApply = new QPushButton( tr( "SMESH_BUT_APPLY" ), GroupButtons );
+ buttonApply->setAutoDefault( true );
+ buttonCancel = new QPushButton( tr( "SMESH_BUT_CLOSE" ), GroupButtons );
+ buttonCancel->setAutoDefault( true );
+ buttonHelp = new QPushButton( tr( "SMESH_BUT_HELP" ), GroupButtons );
+ buttonHelp->setAutoDefault( true );
+ GroupButtonsLayout->addWidget( buttonOk );
+ GroupButtonsLayout->addSpacing(10);
+ GroupButtonsLayout->addWidget( buttonApply );
+ GroupButtonsLayout->addSpacing(10);
+ GroupButtonsLayout->addStretch();
+ GroupButtonsLayout->addWidget( buttonCancel );
+ GroupButtonsLayout->addWidget( buttonHelp );
+
+ ModeStackedLayout->addWidget( ModeActiveWidget );
+ ModeStackedLayout->addWidget( GroupParameters );
+
+ SMESHGUI_ClippingDlgLayout->addWidget( GroupPlanes );
+ SMESHGUI_ClippingDlgLayout->addLayout( ModeStackedLayout );
+ SMESHGUI_ClippingDlgLayout->addWidget( CheckBoxWidget );
+ SMESHGUI_ClippingDlgLayout->addWidget( GroupButtons );
+
+ // Initializations
+ initParam();
+
+ myIsSelectPlane = false;
+
+ myHelpFileName = "clipping_page.html";
+
+ // signals and slots connections :
+ connect( ComboBoxPlanes, SIGNAL( activated( int ) ), this, SLOT( onSelectPlane( int ) ) );
+ connect( isOpenGLClipping, SIGNAL( toggled( bool ) ), this, SLOT( onIsOpenGLClipping( bool ) ) );
+ connect( buttonNew, SIGNAL( clicked() ), buttonNew, SLOT( showMenu() ) );
+ connect( buttonDelete, SIGNAL( clicked() ), this, SLOT( ClickOnDelete() ) );
+ connect( ActorList, SIGNAL( itemChanged( QListWidgetItem* ) ), this, SLOT( onActorItemChanged( QListWidgetItem*) ) );
+ connect( SelectAllCheckBox, SIGNAL( stateChanged( int ) ), this, SLOT( onSelectAll( int ) ) );
+
+ connect( invertButton, SIGNAL (clicked() ), this, SLOT( onInvert() ) ) ;
+ connect( resetButton, SIGNAL (clicked() ), this, SLOT( onReset() ) );
+ connect( SpinBox_X, SIGNAL ( valueChanged( double ) ), this, SLOT( SetCurrentPlaneParam() ) );
+ connect( SpinBox_Y, SIGNAL ( valueChanged( double ) ), this, SLOT( SetCurrentPlaneParam() ) );
+ connect( SpinBox_Z, SIGNAL ( valueChanged( double ) ), this, SLOT( SetCurrentPlaneParam() ) );
+ connect( SpinBox_Dx, SIGNAL ( valueChanged( double ) ), this, SLOT( SetCurrentPlaneParam() ) );
+ connect( SpinBox_Dy, SIGNAL ( valueChanged( double ) ), this, SLOT( SetCurrentPlaneParam() ) );
+ connect( SpinBox_Dz, SIGNAL ( valueChanged( double ) ), this, SLOT( SetCurrentPlaneParam() ) );
+ connect( CBAbsoluteOrientation, SIGNAL ( activated ( int ) ), this, SLOT( onSelectAbsoluteOrientation( int ) ) ) ;
+
+ connect( CBRelativeOrientation, SIGNAL( activated( int ) ), this, SLOT( onSelectRelativeOrientation( int ) ) );
+ connect( SliderDistance, SIGNAL( sliderMoved( int ) ), this, SLOT( SliderDistanceHasMoved( int ) ) );
+ connect( SliderDistance, SIGNAL( valueChanged( int ) ), this, SLOT( SliderDistanceHasMoved( int ) ) );
+ connect( SliderRotation1, SIGNAL( sliderMoved( int ) ), this, SLOT( SliderRotation1HasMoved( int ) ) );
+ connect( SliderRotation1, SIGNAL( valueChanged( int ) ), this, SLOT( SliderRotation1HasMoved( int ) ) );
+ connect( SliderRotation2, SIGNAL( sliderMoved( int ) ), this, SLOT( SliderRotation2HasMoved( int ) ) );
+ connect( SliderRotation2, SIGNAL( valueChanged( int ) ), this, SLOT( SliderRotation2HasMoved( int ) ) );
+
+ connect( PreviewCheckBox, SIGNAL( toggled( bool ) ), this, SLOT( OnPreviewToggle( bool ) ) );
+ connect( AutoApplyCheckBox, SIGNAL( toggled( bool ) ), this, SLOT( onAutoApply( bool ) ) );
+ connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
+ connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
+ connect( buttonApply, SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
+ connect( buttonHelp, SIGNAL( clicked() ), this, SLOT( ClickOnHelp() ) );
+ connect( mySMESHGUI, SIGNAL ( SignalCloseAllDialogs() ), this, SLOT( reject() ) );
+ /* to close dialog if study frame change */
+ connect( mySMESHGUI, SIGNAL ( SignalStudyFrameChanged() ), this, SLOT( reject() ) );
+
+ initializePlaneData();
+ synchronize();
+
+ this->show();
+}
+
+/*!
+ Destructor
+ Destroys the object and frees any allocated resources
+*/
+SMESHGUI_ClippingDlg::~SMESHGUI_ClippingDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+ std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisibility(false));
+ if (myViewWindow)
+ SMESH::RenderViewWindow(myViewWindow);
+
+ for( int i=0; i< myPlanes.size(); i++ ) {
+ SMESH::TPlaneData aPlaneData = myPlanes[i];
+ aPlaneData.Plane->Delete();