}
}
-void RangeStepAndValidator (QAD_SpinBoxDbl* theSpinBox, double min, double max,
+ void RangeStepAndValidator (QAD_SpinBoxDbl* theSpinBox, double min, double max,
double step, unsigned short decimals)
{
theSpinBox->setRange(min, max);
//=======================================================================
//class : OrientedPlane
-//purpose :
+//purpose :
//=======================================================================
class OrientedPlane: public vtkPlane
QAD_Study* myStudy;
QAD_StudyFrame* myStudyFrame;
VTKViewer_ViewFrame* myViewFrame;
-
+
vtkDataSetMapper* myMapper;
public:
return new OrientedPlane(theStudy);
}
vtkTypeMacro(OrientedPlane, vtkPlane);
-
-
+
+
VISU::Orientation myOrientation;
float myDistance;
double myAngle[2];
vtkPlaneSource* myPlaneSource;
SALOME_Actor *myActor;
-
+
void SetOrientation(VISU::Orientation theOrientation) {myOrientation = theOrientation;}
VISU::Orientation GetOrientation() {return myOrientation;}
// Create and display actor
myMapper = vtkDataSetMapper::New();
myMapper->SetInput( myPlaneSource->GetOutput() );
-
+
myActor = SALOME_Actor::New();
myActor->VisibilityOff();
myActor->PickableOff();
aProp->SetOpacity(0.75);
myActor->SetProperty( aProp );
aProp->Delete();
-
+
vtkProperty* aBackProp = vtkProperty::New();
anRGB[0] = VISU::GetFloat("SMESH:SettingsBackFaceColorRed", 0)/255.;
anRGB[1] = VISU::GetFloat("SMESH:SettingsBackFaceColorGreen", 0)/255.;
myPlaneSource->UnRegisterAllOutputs();
myPlaneSource->Delete();
};
-
+
private:
// Not implemented.
- OrientedPlane(const OrientedPlane&);
+ OrientedPlane(const OrientedPlane&);
void operator=(const OrientedPlane&);
};
//=================================================================================
// class : VisuGUI_ClippingDlg()
-// purpose :
+// purpose :
//
//=================================================================================
VisuGUI_ClippingDlg::VisuGUI_ClippingDlg (QWidget* parent,
setName( "VisuGUI_ClippingDlg" );
setCaption( tr( "VISU_CLIPPING_TITLE" ) );
setSizeGripEnabled( TRUE );
- QGridLayout* VisuGUI_ClippingDlgLayout = new QGridLayout( this );
+ QGridLayout* VisuGUI_ClippingDlgLayout = new QGridLayout( this );
VisuGUI_ClippingDlgLayout->setSpacing( 6 );
VisuGUI_ClippingDlgLayout->setMargin( 11 );
GroupPlanesLayout->setAlignment( Qt::AlignTop );
GroupPlanesLayout->setSpacing( 6 );
GroupPlanesLayout->setMargin( 11 );
-
+
ComboBoxPlanes = new QComboBox(GroupPlanes, "ComboBoxPlanes");
GroupPlanesLayout->addWidget( ComboBoxPlanes, 0, 0 );
-
+
QSpacerItem* spacerGP = new QSpacerItem( 20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum );
GroupPlanesLayout->addItem( spacerGP, 0, 1 );
-
+
buttonNew = new QPushButton( GroupPlanes, "buttonNew" );
buttonNew->setText( tr( "VISU_BUT_NEW" ) );
GroupPlanesLayout->addWidget( buttonNew, 0, 2 );
-
+
buttonDelete = new QPushButton( GroupPlanes, "buttonDelete" );
buttonDelete->setText( tr( "VISU_BUT_DELETE" ) );
GroupPlanesLayout->addWidget( buttonDelete, 0, 3 );
QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
GroupButtons->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)7, (QSizePolicy::SizeType)0, 0, 0, GroupButtons->sizePolicy().hasHeightForWidth() ) );
- GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
+ GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
GroupButtons->setTitle( tr( "" ) );
GroupButtons->setColumnLayout(0, Qt::Vertical );
GroupButtons->layout()->setSpacing( 0 );
VisuGUI_ClippingDlgLayout->addWidget( PreviewCheckBox, 2, 0 );
VisuGUI_ClippingDlgLayout->addWidget( AutoApplyCheckBox, 2, 1 );
VisuGUI_ClippingDlgLayout->addMultiCellWidget( GroupButtons, 3, 3, 0, 1 );
-
+
// mySelection = SALOME_Selection::Selection( VisuGUI::GetVisuGUI()->GetActiveStudy()->getSelection());
// Initial state
myPrs3d = 0;
myIsSelectPlane = false;
onSelectionChanged();
-
+
// signals and slots connections :
connect( ComboBoxPlanes, SIGNAL( activated( int )), this, SLOT( onSelectPlane( int ) ) );
connect( buttonNew, SIGNAL( clicked() ), this, SLOT( ClickOnNew() ) );
connect( SpinBoxIJKIndex, SIGNAL( valueChanged( int )), this, SLOT( SetCurrentPlaneIJKParam()));
connect( CheckBoxIJKPlaneReverse, SIGNAL(toggled(bool)), this, SLOT( SetCurrentPlaneIJKParam()));
connect( TabPane, SIGNAL( currentChanged ( QWidget* )), this, SLOT( onTabChanged( QWidget* )));
-
+
connect( PreviewCheckBox, SIGNAL( toggled( bool )), this, SLOT( OnPreviewToggle( bool ) ) );
connect( AutoApplyCheckBox, SIGNAL( toggled( bool )), this, SLOT( ClickOnApply() ) );
connect( buttonOk, SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
//=======================================================================
//function : createParamsTab
-//purpose :
+//purpose :
//=======================================================================
QWidget* VisuGUI_ClippingDlg::createParamsTab()
GroupParametersLayout->setAlignment( Qt::AlignTop );
GroupParametersLayout->setSpacing( 6 );
GroupParametersLayout->setMargin( 11 );
-
+
TextLabelOrientation = new QLabel( GroupParameters, "TextLabelOrientation" );
TextLabelOrientation->setText( tr("TXT_ORIENTATION") );
GroupParametersLayout->addWidget( TextLabelOrientation, 0, 0 );
-
+
ComboBoxOrientation = new QComboBox(GroupParameters, "ComboBoxOrientation");
GroupParametersLayout->addWidget( ComboBoxOrientation, 0, 1 );
-
+
TextLabelDistance = new QLabel( GroupParameters, "TextLabelDistance" );
TextLabelDistance->setText( tr("VISU_DISTANCE") );
GroupParametersLayout->addWidget( TextLabelDistance, 1, 0 );
SpinBoxRot1 = new QAD_SpinBoxDbl( GroupParameters, "SpinBoxRot1" );
GroupParametersLayout->addWidget( SpinBoxRot1, 2, 1 );
-
+
TextLabelRot2 = new QLabel( GroupParameters, "TextLabelRot2" );
TextLabelRot2->setText( tr("Rotation around Y (X to Z):") );
GroupParametersLayout->addWidget( TextLabelRot2, 3, 0 );
-
+
SpinBoxRot2 = new QAD_SpinBoxDbl( GroupParameters, "SpinBoxRot2" );
GroupParametersLayout->addWidget( SpinBoxRot2, 3, 1 );
//=======================================================================
//function : createIJKParamsTab
-//purpose :
+//purpose :
//=======================================================================
QWidget* VisuGUI_ClippingDlg::createIJKParamsTab()
IJKParametersLayout->setSpacing( 6 );
IJKParametersLayout->setMargin( 11 );
- // Axis group
+ // Axis group
ButtonGroupIJKAxis = new QHButtonGroup( QObject::tr( "Axis" ), WidgetIJKTab);
new QRadioButton( QObject::tr( "I" ), ButtonGroupIJKAxis); // 0
new QRadioButton( QObject::tr( "J" ), ButtonGroupIJKAxis); // 1
new QRadioButton( QObject::tr( "K" ), ButtonGroupIJKAxis); // 2
ButtonGroupIJKAxis->setButton(0);
- // Index
+ // Index
TextLabelIJKIndex = new QLabel( WidgetIJKTab, "TextLabelIJKIndex" );
TextLabelIJKIndex->setText( tr( "Index (from 0 to 0)" ));
SpinBoxIJKIndex = new QSpinBox( WidgetIJKTab, "SpinBoxIJKIndex");
- // Orientation
+ // Orientation
CheckBoxIJKPlaneReverse = new QCheckBox( tr("Reverse normal"), WidgetIJKTab);
CheckBoxIJKPlaneReverse->setChecked(false);
if (VisuGUI::GetActiveStudy()->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
QAD_WaitCursor wc;
-
+
myPrs3d->RemoveAllClippingPlanes();
VISU::TPlanes::iterator anIter = myPlanes.begin();
std::for_each(myPlanes.begin(),myPlanes.end(),TSetVisiblity(false));
myPlanes.clear();
+ float anOffset [3];
+ myPrs3d->GetOffset(anOffset);
+
vtkIdType anId = 0, anEnd = myPrs3d->GetNumberOfClippingPlanes();
for (; anId < anEnd; anId++) {
if (vtkImplicitFunction* aFunction = myPrs3d->GetClippingPlane(anId)) {
VISU::TVTKPlane aTVTKPlane(anOrientedPlane);
anOrientedPlane->Delete();
aTVTKPlane->ShallowCopy(aPlane);
+ aTVTKPlane->myActor->SetPosition(anOffset);
myPlanes.push_back(aTVTKPlane);
}
}
// purpose :
//=======================================================================
void VisuGUI_ClippingDlg::onSelectPlane(int theIndex)
-{
+{
if (!myPrs3d || myPlanes.empty())
return;
OrientedPlane* aPlane = myPlanes[theIndex].GetPointer();
-
+
// Orientation
VISU::Orientation anOrientation = aPlane->GetOrientation();
-
+
// Rotations
double aRot[2] = {aPlane->myAngle[0], aPlane->myAngle[1]};
{
if (!myPrs3d)
return;
-
+
OrientedPlane* aPlane = OrientedPlane::New(VisuGUI::GetActiveStudy());
VISU::TVTKPlane aTVTKPlane(aPlane);
myPlanes.push_back(aTVTKPlane);
+ float anOffset [3];
+ myPrs3d->GetOffset(anOffset);
+ aTVTKPlane->myActor->SetPosition(anOffset);
+
if (PreviewCheckBox->isChecked())
aTVTKPlane->myActor->VisibilityOn();
{
if (!myPrs3d || myPlanes.empty())
return;
-
+
int aPlaneIndex = ComboBoxPlanes->currentItem();
-
+
VISU::TPlanes::iterator anIter = myPlanes.begin() + aPlaneIndex;
anIter->GetPointer()->myActor->SetVisibility(false);
myPlanes.erase(anIter);
-
+
if(AutoApplyCheckBox->isChecked())
ClickOnApply();
{
if (myPlanes.empty())
return;
-
+
if (theItem == 0) {
TextLabelRot1->setText( tr( "Rotation around X (Y to Z):") );
TextLabelRot2->setText( tr( "Rotation around Y (X to Z):" ) );
TextLabelRot1->setText( tr( "Rotation around Z (X to Y):" ) );
TextLabelRot2->setText( tr( "Rotation around X (Z to Y):" ) );
}
-
+
if((QComboBox*)sender() == ComboBoxOrientation)
SetCurrentPlaneParam();
}
{
int aNbPlanes = myPlanes.size();
ComboBoxPlanes->clear();
-
+
QString aName;
for(int i = 1; i<=aNbPlanes ; i++){
aName = QString(tr("Plane# %1")).arg(i);
ComboBoxPlanes->insertItem(aName);
}
-
+
int aPos = ComboBoxPlanes->count() - 1;
ComboBoxPlanes->setCurrentItem(aPos);
-
+
bool anIsControlsEnable = (aPos >= 0);
if(anIsControlsEnable){
onSelectPlane(aPos);
{
if (myPlanes.empty() || myIsSelectPlane)
return;
-
+
int aCurPlaneIndex = ComboBoxPlanes->currentItem();
-
+
OrientedPlane* aPlane = myPlanes[aCurPlaneIndex].GetPointer();
-
+
float aNormal[3];
VISU::Orientation anOrientation;
float aDir[3][3] = {{0, 0, 0}, {0, 0, 0}};
- {
+ {
static double aCoeff = vtkMath::Pi()/180.0;
float aRot[2] = {getRotation1(), getRotation2()};
float aV[2] = {sqrt(1.0-anU[0]*anU[0]), sqrt(1.0-anU[1]*anU[1])};
aV[0] = aRot[0] > 0? aV[0]: -aV[0];
aV[1] = aRot[1] > 0? aV[1]: -aV[1];
-
+
switch (ComboBoxOrientation->currentItem()) {
- case 0:
- anOrientation = VISU::XY;
+ case 0:
+ anOrientation = VISU::XY;
aDir[0][1] = anU[0];
aDir[0][2] = aV[0];
aDir[1][2] = aV[1];
break;
- case 1:
- anOrientation = VISU::YZ;
+ case 1:
+ anOrientation = VISU::YZ;
aDir[0][2] = anU[0];
aDir[0][0] = aV[0];
aDir[1][0] = aV[1];
break;
- case 2:
- anOrientation = VISU::ZX;
+ case 2:
+ anOrientation = VISU::ZX;
aDir[0][0] = anU[0];
aDir[0][1] = aV[0];
vtkMath::Normalize(aNormal);
vtkMath::Cross(aNormal,aDir[1],aDir[0]);
}
-
+
aPlane->SetOrientation(anOrientation);
aPlane->SetDistance(getDistance());
-
+
myPrs3d->SetPlaneParam(aNormal, 1. - getDistance(), aPlane);
vtkDataSet* aDataSet = myPrs3d->GetInput();
{aDir[1][0]*aDel, aDir[1][1]*aDel, aDir[1][2]*aDel}};
float aParam, aPnt0[3], aPnt1[3], aPnt2[3];
- float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0],
- aPnt[1] - aDelta[0][1] - aDelta[1][1],
+ float aPnt01[3] = {aPnt[0] - aDelta[0][0] - aDelta[1][0],
+ aPnt[1] - aDelta[0][1] - aDelta[1][1],
aPnt[2] - aDelta[0][2] - aDelta[1][2]};
- float aPnt02[3] = {aPnt01[0] + aNormal[0],
- aPnt01[1] + aNormal[1],
+ float aPnt02[3] = {aPnt01[0] + aNormal[0],
+ aPnt01[1] + aNormal[1],
aPnt01[2] + aNormal[2]};
vtkPlane::IntersectWithLine(aPnt01,aPnt02,aNormal,anOrigin,aParam,aPnt0);
- float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0],
- aPnt[1] - aDelta[0][1] + aDelta[1][1],
+ float aPnt11[3] = {aPnt[0] - aDelta[0][0] + aDelta[1][0],
+ aPnt[1] - aDelta[0][1] + aDelta[1][1],
aPnt[2] - aDelta[0][2] + aDelta[1][2]};
- float aPnt12[3] = {aPnt11[0] + aNormal[0],
- aPnt11[1] + aNormal[1],
+ float aPnt12[3] = {aPnt11[0] + aNormal[0],
+ aPnt11[1] + aNormal[1],
aPnt11[2] + aNormal[2]};
vtkPlane::IntersectWithLine(aPnt11,aPnt12,aNormal,anOrigin,aParam,aPnt1);
- float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0],
- aPnt[1] + aDelta[0][1] - aDelta[1][1],
+ float aPnt21[3] = {aPnt[0] + aDelta[0][0] - aDelta[1][0],
+ aPnt[1] + aDelta[0][1] - aDelta[1][1],
aPnt[2] + aDelta[0][2] - aDelta[1][2]};
- float aPnt22[3] = {aPnt21[0] + aNormal[0],
- aPnt21[1] + aNormal[1],
+ float aPnt22[3] = {aPnt21[0] + aNormal[0],
+ aPnt21[1] + aNormal[1],
aPnt21[2] + aNormal[2]};
vtkPlane::IntersectWithLine(aPnt21,aPnt22,aNormal,anOrigin,aParam,aPnt2);
//=======================================================================
//function : onTabChanged
-//purpose :
+//purpose :
//=======================================================================
void VisuGUI_ClippingDlg::onTabChanged( QWidget* newTab)
VISU::Result_i* result = myPrs3d ? myPrs3d->GetResult() : 0;
if ( !result )
return;
-
+
// get axis data
int i, axId = ButtonGroupIJKAxis->id ( ButtonGroupIJKAxis->selected() );
VISU::Result_i::TAxis axis = (VISU::Result_i::TAxis) axId;