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