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