]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_CutLinesDlg.cxx
Salome HOME
Merge with version on tag OCC-V2_1_0d
[modules/visu.git] / src / VISUGUI / VisuGUI_CutLinesDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : VisuGUI_CutLinesDlg.cxx
8 //  Author : VSV
9 //  Module : VISU
10
11 #include "VisuGUI_CutLinesDlg.h"
12 #include "VISU_CutLines_i.hh"
13 #include "VisuGUI.h"
14 #include "VISU_PipeLine.hxx"
15 #include "VTKViewer_ViewFrame.h"
16 #include "VISU_CutLinesPL.hxx"
17 #include "VISU_Gen_i.hh"
18
19 #include "QAD_Application.h"
20 #include "QAD_Desktop.h"
21
22 #include <qlayout.h>
23 #include <qhbox.h>
24 #include <qtabwidget.h>
25 #include <qhgroupbox.h>
26
27 #include <vtkRenderer.h>
28 #include <vtkPolyData.h>
29 #include <vtkAppendPolyData.h>
30 #include <vtkDataSetMapper.h>
31
32 using namespace std;
33
34 extern VisuGUI *visuGUI;
35
36 #include  "QAD_RightFrame.h"
37 #define GET_VTK_VIEWFRAME(aStudy) dynamic_cast<VTKViewer_ViewFrame*>(aStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())
38
39 bool VisuGUI_CutLinesDlg::MYGenerateTable = true;
40 bool VisuGUI_CutLinesDlg::MYGenerateCurve = true;
41
42 VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg(bool theIsCreation)
43     : QDialog(  QAD_Application::getDesktop(), "VisuGUI_CutLinesDlg", false, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu | WDestructiveClose), 
44       myPreviewActor(0),
45       myStudy(QAD_Application::getDesktop()->getActiveStudy())
46 {
47   myStudyFrame = myStudy -> getActiveStudyFrame();
48   setCaption( "Cut Lines Definition" );
49   setSizeGripEnabled( true );
50   myIsCreation = theIsCreation;
51   
52   QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
53   aMainLayout->setSpacing(5);
54   
55   hasInit = false; 
56   
57   // Tab pane
58   QTabWidget* aTabPane = new QTabWidget(this);
59
60   // Plane of lines
61   QFrame* aPlanePane = new QFrame(this);
62   QVBoxLayout* aPlaneLayout = new QVBoxLayout( aPlanePane, 5, 6 ); 
63     
64   mySelPlane = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aPlanePane);
65   mySelPlane->setInsideSpacing( 5 );
66   mySelPlane->setInsideMargin( 5 );
67     
68   QRadioButton* aBxy = new QRadioButton( tr( "|| X-Y" ), mySelPlane);  // 0
69   QRadioButton* aByz = new QRadioButton( tr( "|| Y-Z" ), mySelPlane);  // 1
70   QRadioButton* aBzx = new QRadioButton( tr( "|| Z-X" ), mySelPlane);  // 2
71   aBzx->setChecked(true);
72
73   aPlaneLayout->addWidget( mySelPlane );
74    
75   QGroupBox* aRotBox = new QGroupBox( tr( "LBL_ROTATION" ), aPlanePane );
76   aRotBox->setColumnLayout(2, Qt::Horizontal );
77
78   myRotXLbl = new QLabel( tr( "LBL_ROT_X" ), aRotBox);
79   myRotXSpn = new QAD_SpinBoxDbl( aRotBox, -45, 45, 5 );
80   myRotXSpn->setValue( 0 );
81   myRotYLbl = new QLabel( tr( "LBL_ROT_Y" ), aRotBox );
82   myRotYSpn = new QAD_SpinBoxDbl( aRotBox, -45, 45, 5 );
83   myRotYSpn->setValue( 0 );
84
85   aPlaneLayout->addWidget( aRotBox );
86     
87   QHGroupBox* aBaseBox = new QHGroupBox( tr( "Base plane position" ), aPlanePane );
88   myBasePlanePos = new QLineEdit (aBaseBox);
89   mydvalidator = new QDoubleValidator(this);
90   mydvalidator->setDecimals(32);
91   myBasePlanePos->setValidator(mydvalidator);
92
93   myCBSetDef = new QCheckBox(tr("Set default"),aBaseBox);
94   
95   aPlaneLayout->addWidget( aBaseBox );
96   
97   QHBox* aPosBox = new QHBox(aPlanePane);
98   aPosBox->setSpacing(5);
99   QLabel* aPosLbl = new QLabel( tr( "LBL_POS" ), aPosBox );
100   myPosSpn = new QAD_SpinBoxDbl( aPosBox, 0, 1, 0.1 );
101   myPosSpn->setValue( 0.5 );  
102   aPlaneLayout->addWidget( aPosBox );
103
104   myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), aPlanePane);
105   myPreviewCheck->setChecked(false);
106   aPlaneLayout->addWidget( myPreviewCheck );
107
108   myCreateTable = new QCheckBox(tr("LBL_GENERATE_TABLE"), aPlanePane);
109   myCreateTable->setChecked(MYGenerateTable);
110   aPlaneLayout->addWidget( myCreateTable );
111
112   QHBox* aCheckPane = new QHBox(aPlanePane);
113   QLabel* aLbl = new QLabel("   ", aCheckPane);
114   aCheckPane->setStretchFactor(aLbl, 0);
115   myCurvesCheck = new QCheckBox(tr("LBL_GENERATE_CURVES"), aCheckPane);
116   aCheckPane->setStretchFactor(aCheckPane, 0);
117   myCurvesCheck->setChecked(MYGenerateCurve);
118   myCurvesCheck->setEnabled(MYGenerateTable);
119   QLabel* aLbl2 = new QLabel("   ", aCheckPane);
120   aCheckPane->setStretchFactor(aLbl2, 1);
121   aPlaneLayout->addWidget( aCheckPane );
122
123   aPlaneLayout->addStretch();
124
125
126   aTabPane->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
127   
128   // Number of lines
129   QFrame* aLinesPane = new QFrame(this);
130   QVBoxLayout* aLinesLayout = new QVBoxLayout( aLinesPane, 5, 6 ); 
131   
132   mySelPlane2 = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aLinesPane);
133   mySelPlane2->setInsideSpacing( 5 );
134   mySelPlane2->setInsideMargin( 5 );
135  
136   QRadioButton* aBxy2 = new QRadioButton( tr( "|| X-Y" ), mySelPlane2);  // 0
137   QRadioButton* aByz2 = new QRadioButton( tr( "|| Y-Z" ), mySelPlane2);  // 1
138   QRadioButton* aBzx2 = new QRadioButton( tr( "|| Z-X" ), mySelPlane2);  // 2
139   aBzx2->setEnabled(false);
140   aByz2->setChecked(true);
141   aLinesLayout->addWidget( mySelPlane2 );
142
143   QGroupBox* aRotBox2 = new QGroupBox( tr( "LBL_ROTATION" ), aLinesPane );
144   aRotBox2->setColumnLayout(2, Qt::Horizontal );
145   
146   myRotXLbl2 = new QLabel( tr( "LBL_ROT_X" ), aRotBox2);
147   myRotXSpn2 = new QAD_SpinBoxDbl( aRotBox2, -45, 45, 5 );
148   myRotXSpn2->setValue( 0 );
149   myRotYLbl2 = new QLabel( tr( "LBL_ROT_Y" ), aRotBox2 );
150   myRotYSpn2 = new QAD_SpinBoxDbl( aRotBox2, -45, 45, 5 );
151   myRotYSpn2->setValue( 0 );
152   aLinesLayout->addWidget( aRotBox2 );
153
154   QHBox* aNbBox = new QHBox(aLinesPane);
155   aNbBox->setSpacing(5);
156   QLabel* aNbLbl = new QLabel( tr( "LBL_NB_PLANS" ), aNbBox );
157   myNbSpn = new QAD_SpinBoxDbl( aNbBox, 1, 100, 1 );
158   myNbSpn->setValue( 10 );  
159  
160   aLinesLayout->addWidget( aNbBox );
161
162   myPosTable = new QTable(aLinesPane, "Positions of cut planes" );
163   myPosTable->setMaximumHeight( 227 );
164   myPosTable->setMinimumWidth( 294 );
165   myPosTable->setNumCols(2);
166   myPosTable->setNumRows(0);
167   
168   QHeader *th = myPosTable->horizontalHeader();
169   th->setLabel( 0, "Position" );
170   th->setLabel( 1, "Set default" );
171
172   aLinesLayout->addWidget( myPosTable );
173
174   QHBox* aPosBox2 = new QHBox(aLinesPane);
175   aPosBox2->setSpacing(5);
176   QLabel* aPosLbl2 = new QLabel( tr( "LBL_POS" ), aPosBox2 );
177   myPosSpn2 = new QAD_SpinBoxDbl( aPosBox2, 0, 1, 0.1 );
178   myPosSpn2->setValue( 0.5 );  
179   aLinesLayout->addWidget( aPosBox2 );
180   aLinesLayout->addStretch();
181  
182   aTabPane->addTab( aLinesPane, tr("LBL_LINES_CUT") );
183
184   myScalarPane = new VisuGUI_ScalarBarPane(this, false);
185   myScalarPane->setMargin( 5 );
186   aTabPane->addTab(myScalarPane, "Scalar Bar");
187
188   aMainLayout->addWidget(aTabPane);
189
190   // Dialog buttons
191   QHBox* aBtnBox = new QHBox(this);
192   aBtnBox->setFrameStyle(QFrame::Box | QFrame::Sunken);
193   aBtnBox->setLineWidth( 1 );
194   QHBoxLayout* aBtnLayout = (QHBoxLayout*) aBtnBox->layout(); 
195   aBtnLayout->setAutoAdd( false );
196   aBtnLayout->setSpacing( 5 );
197   aBtnLayout->setMargin( 11 );
198
199   QPushButton* aOkBtn = new QPushButton(tr( "VISU_BUT_OK" ),  aBtnBox);
200   aOkBtn->setAutoDefault( TRUE );
201   aOkBtn->setDefault( true );
202   aBtnLayout->addWidget(aOkBtn);
203  
204   aBtnLayout->addStretch();
205   
206   QPushButton* aCloseBtn = new QPushButton(tr("BUT_CANCEL"), aBtnBox);
207   aBtnLayout->addWidget(aCloseBtn);
208    
209   aMainLayout->addWidget(aBtnBox);
210
211   myCutLines = NULL;
212   
213   // signals and slots connections
214   connect(mySelPlane, SIGNAL(clicked(int)), this, SLOT(onPlaneSelect(int)));
215   connect(myCBSetDef , SIGNAL( toggled(bool) ), this , SLOT( setBaseDefault() ) );
216   connect(myPosSpn , SIGNAL( valueChanged( double ) ), this , SLOT( setBaseDefault() ) );
217   connect(mySelPlane2, SIGNAL(clicked(int)), this, SLOT(onCutSelect(int)));
218   connect( myNbSpn, SIGNAL( valueChanged( double )), this, SLOT( DrawTable( ) ) );
219   connect( th, SIGNAL( clicked(int)), this, SLOT( setDefault(int) ) );
220   connect( myPosSpn2, SIGNAL( valueChanged( double )), this, SLOT( DrawTable( ) ) );
221   connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
222   connect( myPosTable, SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)) );
223   connect( myRotXSpn, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
224   connect( myRotYSpn, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
225   connect( myRotXSpn2, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
226   connect( myRotYSpn2, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
227   connect( myBasePlanePos, SIGNAL( textChanged(const QString& )), this, SLOT( onPlanePos(const QString& ) ) );
228   connect( myCreateTable, SIGNAL( toggled(bool)), myCurvesCheck, SLOT( setEnabled(bool) ));
229
230   connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
231   connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
232   connect( myStudy, SIGNAL(closed()),  this, SLOT( reject() ) );
233   connect( myStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)), this, SLOT(onFrameActivated(QAD_StudyFrame*)));
234 }
235
236 /*!
237   Destructor
238 */
239 VisuGUI_CutLinesDlg::~VisuGUI_CutLinesDlg()
240 {
241   deletePlanes();
242   if(myCutLines) delete myCutLines; 
243   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy))
244     vf->Repaint();  
245 }
246
247 //------------------------------------------------------------------------------
248 void VisuGUI_CutLinesDlg::initFromPrsObject(VISU::CutLines_i* thePrs) {
249   myPrs = thePrs;
250   myScalarPane->initFromPrsObject(thePrs);
251
252   myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
253   myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
254   myPosSpn->setValue(thePrs->GetDisplacement());
255   setOrientation(thePrs->GetOrientationType());
256   
257   myNbSpn->setValue( thePrs->GetNbLines() );  
258   myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI);
259   myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI);
260   myPosSpn2->setValue(thePrs->GetDisplacement2());
261   setOrientation2(thePrs->GetOrientationType2());
262
263   hasInit = true;
264   myCutLines = new VISU::CutLines_i(thePrs->GetResult(),false);
265   myCutLines->SameAs(thePrs);
266   myBasePlanePos->setText( QString::number(myCutLines->GetBasePlanePosition()) );
267   myCBSetDef->setChecked(thePrs->IsDefault());
268   DrawTable();
269
270   // Draw Preview
271   if (myPreviewCheck->isChecked()) {
272     createPlanes();
273   }
274 }
275
276
277 //------------------------------------------------------------------------------
278 int VisuGUI_CutLinesDlg::storeToPrsObject(VISU::CutLines_i* thePrs) {
279
280   myScalarPane->storeToPrsObject(thePrs);
281
282   thePrs->SetOrientation(getOrientaion(),myRotXSpn->value()*PI/180.,myRotYSpn->value()*PI/180.);
283   thePrs->SetDisplacement(myPosSpn->value());
284   thePrs->SetNbLines((int)myNbSpn->value());
285  
286   thePrs->SetOrientation2(getOrientaion(false),myRotXSpn2->value()*PI/180.,myRotYSpn2->value()*PI/180.);
287   thePrs->SetDisplacement2(myPosSpn2->value());
288   
289   if (!myCBSetDef->isChecked())
290     thePrs->SetBasePlanePosition(myBasePlanePos->text().toDouble());
291   else thePrs->SetDefault();
292   
293   for (int i = 0; i < (int)myNbSpn->value(); ++i) 
294     {
295       if (!((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked())
296         thePrs->SetLinePosition( i, myPosTable->text( i, 0 ).toDouble() );
297       else thePrs->SetDefaultPosition(i);
298     }
299   return 1;
300 }
301
302
303 //------------------------------------------------------------------------------
304 void VisuGUI_CutLinesDlg::createPlanes() {
305   if (myStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
306   if (myCutLines == NULL) return;
307   if (myPreviewActor != 0) return;
308
309   vtkAppendPolyData* aPolyData = myCutLines->GetCutLinesPL()->GetAppendPolyData();
310   vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
311   aPlaneMapper->SetInput(aPolyData->GetOutput());
312   aPlaneMapper->ScalarVisibilityOff();
313
314   myPreviewActor = SALOME_Actor::New();
315   myPreviewActor->PickableOff();
316   myPreviewActor->SetMapper(aPlaneMapper);
317   aPlaneMapper->Delete();
318   GET_VTK_VIEWFRAME(myStudy)->AddActor(myPreviewActor);
319 }
320
321 //------------------------------------------------------------------------------
322 void VisuGUI_CutLinesDlg::deletePlanes() {
323   if (myPreviewActor == 0) return;
324   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy))
325     vf->RemoveActor(myPreviewActor);
326   myPreviewActor->Delete();
327   myPreviewActor = 0;
328 }
329
330
331 //------------------------------------------------------------------------------
332 void VisuGUI_CutLinesDlg::onPlaneSelect(int theId) {
333   for (int i = 0; i < mySelPlane2->count(); i++)
334     mySelPlane2->find(i)->setEnabled(true);
335   QButton* aBtn = mySelPlane2->find(theId);
336   aBtn->setEnabled(false);
337   switch (theId) {
338   case 0:
339     myRotXLbl->setText( tr("LBL_ROT_X"));
340     myRotYLbl->setText( tr("LBL_ROT_Y"));
341     ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);    
342     onCutSelect(1, false);
343     break;
344   case 1:
345     myRotXLbl->setText( tr("LBL_ROT_Y"));
346     myRotYLbl->setText( tr("LBL_ROT_Z"));
347     ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);    
348     onCutSelect(2, false);
349     break;
350   case 2:
351     myRotXLbl->setText( tr("LBL_ROT_Z"));
352     myRotYLbl->setText( tr("LBL_ROT_X"));
353     ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
354     onCutSelect(0, false);
355   }
356   setBaseDefault(false);
357   DrawTable();
358 }
359
360 //------------------------------------------------------------------------------
361 void VisuGUI_CutLinesDlg::onCutSelect(int theId, bool theUpdate) {
362   switch (theId) {
363   case 0:
364     myRotXLbl2->setText( tr("LBL_ROT_X"));
365     myRotYLbl2->setText( tr("LBL_ROT_Y"));
366     break;
367   case 1:
368     myRotXLbl2->setText( tr("LBL_ROT_Y"));
369     myRotYLbl2->setText( tr("LBL_ROT_Z"));
370     break;
371   case 2:
372     myRotXLbl2->setText( tr("LBL_ROT_Z"));
373     myRotYLbl2->setText( tr("LBL_ROT_X"));
374   }
375   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
376     if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
377       myCutLines->SetOrientation2(getOrientaion(false),myRotXSpn2->value()*PI/180.,myRotYSpn2->value()*PI/180.);
378       myCutLines->SetDisplacement2(myPosSpn2->value());
379       myCutLines->GetPL()->Update();
380       deletePlanes();
381       createPlanes();  
382       vf->Repaint();  
383     }
384   }
385 }
386
387 //------------------------------------------------------------------------------
388 void VisuGUI_CutLinesDlg::setBaseDefault(bool theUpdate) {
389   if (!hasInit) return;
390   
391   if ( myCBSetDef->isChecked() )
392     {
393       if (!myCutLines->IsDefault()) myCutLines->SetDefault();
394       myCutLines->SetOrientation(getOrientaion(),myRotXSpn->value()*PI/180.,myRotYSpn->value()*PI/180.);
395       myCutLines->SetDisplacement(myPosSpn->value());
396       float aPos = myCutLines->GetBasePlanePosition();
397       myBasePlanePos->setText( QString::number(aPos) );
398       myBasePlanePos->setEnabled(false);
399       if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
400         if (theUpdate && myPreviewCheck->isChecked() && (myCutLines != NULL)) {
401           myCutLines->SetBasePlanePosition(aPos);
402           myCutLines->GetPL()->Update();
403           deletePlanes();
404           createPlanes();  
405           vf->Repaint();  
406         }
407       }
408     }
409   else myBasePlanePos->setEnabled(true);   
410 }
411
412 //------------------------------------------------------------------------------
413 void VisuGUI_CutLinesDlg::DrawTable()
414 {
415   if (!hasInit) return;
416
417   int aNbRows = myPosTable->numRows();
418   int aNbPlanes = (int)myNbSpn->value();  
419      
420   myCutLines->SetOrientation(getOrientaion(),myRotXSpn->value()*PI/180.,myRotYSpn->value()*PI/180.);
421
422   myCutLines->SetNbLines(aNbPlanes);
423   myCutLines->SetDisplacement2(myPosSpn2->value());
424   myCutLines->SetOrientation2(getOrientaion(false),myRotXSpn2->value()*PI/180.,myRotYSpn2->value()*PI/180.);
425
426   if (aNbRows>0)
427     for (int i = 0; i < aNbRows; ++i) {
428       QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
429       if (aItem == 0) break;
430       if (!aItem->isChecked())
431         myCutLines->SetLinePosition(i, myPosTable->text(i, 0).toDouble());
432     }
433   
434   if (aNbPlanes > aNbRows)
435     myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
436   else if (aNbPlanes < aNbRows)
437     myPosTable->setNumRows(aNbPlanes);
438
439   int aMin = (aNbRows < aNbPlanes)? aNbRows : aNbPlanes;
440   for (int i = 0; i<aMin; i++) {
441     myPosTable->setText(i, 0, QString::number(myCutLines->GetLinePosition(i)));
442     ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(myCutLines->IsDefaultPosition(i));
443   }
444
445   QHeader *vh = myPosTable->verticalHeader();
446   QString str("Plane# %1");
447   for (int i=aMin; i<aNbPlanes; i++) {
448     VisuGUI_NumEditItem* aEditItem = new VisuGUI_NumEditItem(myPosTable, 
449                                                              QTableItem::OnTyping, 
450                                                              QString::number(myCutLines->GetLinePosition(i)));
451     aEditItem->setReplaceable(false);
452     aEditItem->setEnabled(!myCutLines->IsDefaultPosition(i));
453     myPosTable->setItem(i, 0, aEditItem);
454
455     QCheckTableItem* aCheck = new QCheckTableItem(myPosTable, 0);
456     aCheck->setChecked(myCutLines->IsDefaultPosition(i));
457     aCheck->setReplaceable(false);
458     myPosTable->setItem(i, 1, aCheck);
459     
460     vh->setLabel( i, str.arg(i+1) );
461   }
462   // Update preview
463   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
464     if (myPreviewCheck->isChecked()) {
465       myCutLines->GetPL()->Update();
466       deletePlanes();
467       createPlanes();
468       vf->Repaint();
469     }
470   }
471 }
472
473 //------------------------------------------------------------------------------
474 void VisuGUI_CutLinesDlg::setDefault(int all)
475 {
476   myPosTable->setCurrentCell(-1, 1);
477   myPosTable->clearSelection();
478   if (all == 0) return;
479   if (all == 1)
480     for (int i = 0; i < (int)myNbSpn->value(); ++i) 
481       ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(true);
482         
483   for (int i = 0; i < (int)myNbSpn->value(); ++i) {
484     if ( ((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked() ) {
485       myCutLines->SetDefaultPosition(i);
486       myPosTable->setText( i, 0, QString::number(myCutLines->GetLinePosition(i)));
487       myPosTable->item( i, 0 )->setEnabled(false);
488     } else 
489       myPosTable->item( i, 0 )->setEnabled(true); 
490   }
491 }
492
493 //------------------------------------------------------------------------------
494 VISU::CutPlanes::Orientation VisuGUI_CutLinesDlg::getOrientaion(bool IsBasePlane)
495 {
496   QHButtonGroup* aBG;
497   
498   if (IsBasePlane)
499     aBG = mySelPlane;
500   else
501     aBG = mySelPlane2;
502
503   VISU::CutPlanes::Orientation orient;
504   switch (aBG->id(aBG->selected())) {
505   case 0:
506     orient = VISU::CutPlanes::XY;
507     break;
508   case 1:
509     orient = VISU::CutPlanes::YZ;
510     break;
511   case 2:
512     orient = VISU::CutPlanes::ZX;
513   }
514   return orient;
515 }
516
517 //------------------------------------------------------------------------------
518 void VisuGUI_CutLinesDlg::setOrientation( const VISU::CutPlanes::Orientation  orient)
519 {
520   switch (orient) {
521   case VISU::CutPlanes::XY:
522     ((QRadioButton*)mySelPlane->find(0))->setChecked(true);
523     onPlaneSelect(0);
524     break;
525   case VISU::CutPlanes::YZ:
526     ((QRadioButton*)mySelPlane->find(1))->setChecked(true);
527     onPlaneSelect(1);
528     break;
529   case VISU::CutPlanes::ZX:      
530     ((QRadioButton*)mySelPlane->find(2))->setChecked(true);
531     onPlaneSelect(2);
532   }
533 }
534
535 //------------------------------------------------------------------------------
536 void VisuGUI_CutLinesDlg::setOrientation2( const VISU::CutPlanes::Orientation  orient )
537 {
538   switch (orient) {
539   case VISU::CutPlanes::XY:
540     ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
541     onCutSelect(0);
542     break;
543   case VISU::CutPlanes::YZ:
544     ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
545     onCutSelect(1);
546     break;
547   case VISU::CutPlanes::ZX:      
548     ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
549     onCutSelect(2);
550   }
551 }
552
553
554 void VisuGUI_CutLinesDlg::onValueChanged(int theRow, int theCol) {
555   if (theCol == 0) {
556     QString aTxt = myPosTable->text(theRow, 0);
557     bool isChanged = !aTxt.isEmpty();
558     ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
559
560     if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
561       if (myPreviewCheck->isChecked()) {
562         //Update Preview
563         myCutLines->SetLinePosition( theRow, aTxt.toDouble());
564         myCutLines->GetPL()->Update();
565         deletePlanes();
566         createPlanes();
567         vf->Repaint();
568       }
569     }
570   } else {
571     bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
572     if (isDefault) {
573       myCutLines->SetDefaultPosition(theRow);
574       myPosTable->setText(theRow, 0, QString::number(myCutLines->GetLinePosition(theRow)));
575
576       if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
577         if (myPreviewCheck->isChecked()) {
578           //Update Preview
579           myCutLines->GetPL()->Update();
580           deletePlanes();
581           createPlanes();
582           vf->Repaint();
583         }
584       }
585     }
586     myPosTable->item(theRow, 0)->setEnabled(!isDefault);
587   }
588 }
589
590
591 void VisuGUI_CutLinesDlg::accept() {
592   MYGenerateTable = myCreateTable->isChecked();
593   MYGenerateCurve = myCurvesCheck->isChecked();
594   if (myScalarPane->check()) {
595     ((QWidget*)sender())->setDisabled(true);
596     storeToPrsObject(myPrs);
597     if (myIsCreation) {
598       if (isGenerateTable()) {
599         visuGUI->GetVisuGen()->CreateTable(myPrs->GetEntry());
600         if (isGenerateCurves()) {
601           SALOMEDS::Study_var aStudy = myStudy->getStudyDocument();
602           SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(myPrs->GetEntry());
603           if(!aSObject->_is_nil()) {
604             SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
605             SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
606             for ( ;aIter->More(); aIter->Next()) {
607               SALOMEDS::SObject_var aTblObj = aIter->Value();
608               if (!aTblObj->_is_nil()) {
609                 SALOMEDS::GenericAttribute_var anAttr;
610                 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
611                   visuGUI->CreatePlot(aTblObj);
612                 }
613               }
614             }
615           }
616         }
617       }
618       if (myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
619         try {
620           visuGUI->CreateActor(myPrs);
621         }
622         catch (...) {
623           reject();
624           return;
625         }
626         GET_VTK_VIEWFRAME(myStudy)->onViewFitAll(); 
627       }
628     } else {
629       visuGUI->RecreateActor(myPrs); 
630       if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) { 
631         if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) { 
632           vf->getRenderer()->ResetCameraClippingRange(); 
633           vf->Repaint(); 
634         }
635       }
636       // Remove old Table
637       SALOMEDS::Study_var aStudy = myStudy->getStudyDocument();
638       SALOMEDS::SObject_var aSObject = aStudy->FindObjectID(myPrs->GetEntry());
639       if(!aSObject->_is_nil()) {
640         SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
641         SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
642         for ( ;aIter->More(); aIter->Next()) {
643           SALOMEDS::SObject_var aTblObj = aIter->Value();
644           if (!aTblObj->_is_nil()) {
645             SALOMEDS::GenericAttribute_var anAttr;
646             if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
647               aBuilder->RemoveObjectWithChildren(aIter->Value()); // We should have only one child
648               break;
649             }
650           }
651         }
652         if (isGenerateTable()) {
653           visuGUI->GetVisuGen()->CreateTable(aSObject->GetID());
654           if (isGenerateCurves()) {
655             SALOMEDS::Study_var aStudy = myStudy->getStudyDocument();
656             SALOMEDS::ChildIterator_var aIter = aStudy->NewChildIterator( aSObject );
657             SALOMEDS::StudyBuilder_var aBuilder = aStudy->NewBuilder();
658             for ( ;aIter->More(); aIter->Next()) {
659               SALOMEDS::SObject_var aTblObj = aIter->Value();
660               if (!aTblObj->_is_nil()) {
661                 SALOMEDS::GenericAttribute_var anAttr;
662                 if (aTblObj->FindAttribute(anAttr, "AttributeName")) {
663                   visuGUI->CreatePlot(aTblObj);
664                 }
665               }
666             }
667           }
668         }
669       }
670     }
671     myStudy->updateObjBrowser();  
672     QDialog::accept();
673   }
674 }
675
676 void VisuGUI_CutLinesDlg::reject() {
677   if (myIsCreation) {
678     visuGUI->DeletePresentation(myPrs); 
679     myStudy->updateObjBrowser();
680   }
681   QDialog::reject();
682 }
683
684 void VisuGUI_CutLinesDlg::onPreviewCheck(bool thePreview) {
685   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
686     if (thePreview) {
687       storeToPrsObject(myCutLines);
688       myCutLines->GetPL()->Update();
689       createPlanes();
690       vf->onViewFitAll();
691     } else {
692       deletePlanes();
693       vf->Repaint();
694     }
695   }
696 }
697
698 void VisuGUI_CutLinesDlg::onRotation(double theValue) {
699   if (myCutLines == NULL) return;
700   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
701     if (myPreviewCheck->isChecked()) {
702       myCutLines->SetOrientation(getOrientaion(),myRotXSpn->value()*PI/180.,myRotYSpn->value()*PI/180.);
703       myCutLines->SetOrientation2(getOrientaion(false),myRotXSpn2->value()*PI/180.,myRotYSpn2->value()*PI/180.);
704       myCutLines->GetPL()->Update();
705       deletePlanes();
706       createPlanes();  
707       vf->Repaint();  
708     }
709   }
710 }
711
712 void VisuGUI_CutLinesDlg::onPlanePos(const QString& theValue) {
713   if (myCutLines == NULL) return;
714   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
715     if (myPreviewCheck->isChecked()) {
716       myCutLines->SetBasePlanePosition(theValue.toDouble());
717       myCutLines->GetPL()->Update();
718       deletePlanes();
719       createPlanes();  
720       vf->Repaint();  
721     }
722   }
723 }
724
725 void VisuGUI_CutLinesDlg::onFrameActivated( QAD_StudyFrame* theFrame) {
726   if (theFrame != myStudyFrame) 
727     reject();
728 }
729
730
731