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