Salome HOME
DCQ : Merge with Ecole Ete a6.
[modules/visu.git] / src / VISUGUI / VisuGUI_CutPlanesDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 //  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
5 // 
6 //  This library is free software; you can redistribute it and/or 
7 //  modify it under the terms of the GNU Lesser General Public 
8 //  License as published by the Free Software Foundation; either 
9 //  version 2.1 of the License. 
10 // 
11 //  This library is distributed in the hope that it will be useful, 
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of 
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
14 //  Lesser General Public License for more details. 
15 // 
16 //  You should have received a copy of the GNU Lesser General Public 
17 //  License along with this library; if not, write to the Free Software 
18 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
19 // 
20 //  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VisuGUI_CutPlanesDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 #include "VisuGUI_CutPlanesDlg.h"
30 #include "VISU_CutPlanes_i.hh"
31 #include "VISU_CutPlanesPL.hxx"
32
33 #include "VisuGUI.h"
34 #include "VTKViewer_ViewFrame.h"
35
36 #include "QAD_Application.h"
37 #include "QAD_Desktop.h"
38 #include "QAD_RightFrame.h"
39
40 #include <qlayout.h>
41 #include <qcheckbox.h>
42 #include <qstyle.h>
43 #include <qstring.h>
44 #include <qvalidator.h>
45 #include <qlineedit.h>
46 #include <qtabwidget.h>
47
48 #include <vtkRenderer.h>
49 #include <vtkAppendPolyData.h>
50 #include <vtkDataSetMapper.h>
51
52
53 #define GET_VTK_VIEWFRAME(aStudy) dynamic_cast<VTKViewer_ViewFrame*>(aStudy->getActiveStudyFrame()->getRightFrame()->getViewFrame())
54
55 using namespace std;
56
57 extern VisuGUI *visuGUI;
58
59 VisuGUI_CutPlanesPane::VisuGUI_CutPlanesPane(QWidget* theParent, QAD_Study* theStudy)
60   :QFrame(theParent), myPreviewActor(0),myStudy(theStudy)
61 {
62   QGridLayout* TopLayout = new QGridLayout( this ); 
63   TopLayout->setSpacing( 6 );
64   TopLayout->setMargin( 10 );
65
66   QButtonGroup* SelPlane = new QButtonGroup( tr( "Orientation" ), this, "SelPlane" );
67   SelPlane->setTitle( tr( "Orientation" ) );
68   SelPlane->setColumnLayout(0, Qt::Vertical );
69   SelPlane->layout()->setSpacing( 0 );
70   SelPlane->layout()->setMargin( 0 );
71   QGridLayout* SelPlaneLayout = new QGridLayout( SelPlane->layout() );
72   SelPlaneLayout->setAlignment( Qt::AlignTop );
73   SelPlaneLayout->setSpacing( 6 );
74   SelPlaneLayout->setMargin( 11 );
75
76   RBxy = new QRadioButton( tr( "// X-Y" ), SelPlane, "RBxy" );
77   RByz = new QRadioButton( tr( "// Y-Z" ), SelPlane, "RByz" );
78   RBzx = new QRadioButton( tr( "// Z-X" ), SelPlane, "RBzx" );
79   SelPlaneLayout->addWidget( RBxy, 0, 0 );
80   SelPlaneLayout->addWidget( RByz, 0, 1 );
81   SelPlaneLayout->addWidget( RBzx, 0, 2 );
82
83   QLabel* LabelPosi_3 = new QLabel( tr( "Number of planes:" ), this, "LabelPosi_3" );
84
85   nbPlan = new QSpinBox( 1, 100, 1, this, "nbPlan" );
86   nbPlan->setValue( 1 );
87   nbPlan->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
88
89   myPosTable = new QTable(this, "Positions of planes" );
90   myPosTable->setMaximumHeight( 227 );
91   myPosTable->setMinimumWidth( 294 );
92   myPosTable->setNumCols(2);
93   myPosTable->setNumRows(0);
94   connect( myPosTable, SIGNAL(valueChanged(int, int)), this, SLOT(onValueChanged(int, int)) );
95   
96   QHeader *th = myPosTable->horizontalHeader();
97   th->setLabel( 0, "Position" );
98   th->setLabel( 1, "Set default" );
99   th->setStyle("QStyle::CE_PushButton");
100     
101   QGroupBox* GBrot = new QGroupBox( tr( "Rotations" ), this, "GBrot" );
102   GBrot->setColumnLayout(0, Qt::Vertical );
103   GBrot->layout()->setSpacing( 0 );
104   GBrot->layout()->setMargin( 0 );
105   QGridLayout* GBrotLayout = new QGridLayout( GBrot->layout() );
106   GBrotLayout->setAlignment( Qt::AlignTop );
107   GBrotLayout->setSpacing( 6 );
108   GBrotLayout->setMargin( 11 );
109
110   LabelRot1 = new QLabel( tr( "Rotation around X (Y to Z):" ), GBrot, "LabelRot1" );
111   GBrotLayout->addWidget( LabelRot1, 0, 0 );
112
113   Rot1 = new QAD_SpinBoxDbl( GBrot, -180, 180, 10 );
114   Rot1->setValue( 0 );
115   Rot1->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
116   connect( Rot1, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
117   GBrotLayout->addWidget( Rot1, 0, 1 );
118
119   LabelRot2 = new QLabel( tr( "Rotation around Y (Z to X):" ), GBrot, "LabelRot2" );
120   GBrotLayout->addWidget( LabelRot2, 1, 0 );
121   
122   Rot2 = new QAD_SpinBoxDbl( GBrot, -180, 180, 10 );
123   Rot2->setValue( 0 );
124   Rot2->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
125   connect( Rot2, SIGNAL( valueChanged( double )), this, SLOT( onRotation( double ) ) );
126   GBrotLayout->addWidget( Rot2, 1, 1 );
127
128   QLabel* aPosLbl = new QLabel(tr( "LBL_POS" ), this);
129   myPosSpn = new QAD_SpinBoxDbl( this, 0, 1, 0.1 );
130
131   myPreviewCheck = new QCheckBox(tr("LBL_SHOW_PREVIEW"), this);
132   myPreviewCheck->setChecked(false);
133   connect( myPreviewCheck, SIGNAL( toggled( bool )), this, SLOT( onPreviewCheck( bool ) ) );
134
135   TopLayout->addMultiCellWidget( SelPlane, 0, 0, 0, 1 );
136   TopLayout->addMultiCellWidget( GBrot, 1, 1, 0, 1 );
137   TopLayout->addWidget( LabelPosi_3,   2, 0 );
138   TopLayout->addWidget( nbPlan,        2, 1 );
139   TopLayout->addMultiCellWidget( myPosTable, 3, 3, 0, 1 );
140   TopLayout->setRowStretch ( 3, 3 );
141   TopLayout->addWidget(aPosLbl, 4, 0 );
142   TopLayout->addWidget(myPosSpn, 4, 1 );
143   TopLayout->addMultiCellWidget( myPreviewCheck, 5, 5, 0, 1 );
144
145   // signals and slots connections
146   connect( SelPlane, SIGNAL( clicked( int )), this, SLOT( orientationChanged( int ) ) );
147   connect( nbPlan, SIGNAL( valueChanged( int )), this, SLOT( DrawTable( ) ) );
148   connect( myPosSpn, SIGNAL( valueChanged( double )), this, SLOT( DrawTable( ) ) );
149   connect( th, SIGNAL( clicked(int)), this, SLOT( setDefault(int) ) );
150
151   // default values
152   myCutPlanes = NULL;
153   hasInit = false;
154   X1 = 0; X2 = 0;
155   Y1 = 0; Y2 = 0;
156   Z1 = 0; Z2 = 0;
157   RByz->setChecked( true );
158   
159 } // End of Constructor
160
161
162 VisuGUI_CutPlanesPane::~VisuGUI_CutPlanesPane()
163 {
164   deletePlanes();
165   if(myCutPlanes) myCutPlanes->Destroy();
166   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy))
167     vf->Repaint();
168 }
169
170
171 void VisuGUI_CutPlanesPane::initFromPrsObject(VISU::CutPlanes_i* thePrs) {
172   setNbPlanes(thePrs->GetNbPlanes());
173   setRotation(thePrs->GetRotateX()*180./PI, thePrs->GetRotateY()*180./PI);
174   setPlanePos(thePrs->GetOrientationType());
175   myPosSpn->setValue(thePrs->GetDisplacement());
176   hasInit = true;
177   // init table
178   myCutPlanes = new VISU::CutPlanes_i(thePrs->GetResult(),false);
179   myCutPlanes->SameAs(thePrs);
180   DrawTable();
181
182   // Draw Preview
183   if (myPreviewCheck->isChecked()) {
184     createPlanes();
185   }
186 }
187
188
189 void VisuGUI_CutPlanesPane::createPlanes() {
190   if (myStudy->getActiveStudyFrame()->getTypeView() != VIEW_VTK) return;
191   if (myCutPlanes == NULL) return;
192   if (myPreviewActor != 0) return;
193
194   vtkAppendPolyData* aPolyData = myCutPlanes->GetCutPlanesPL()->GetAppendPolyData();
195   vtkDataSetMapper* aPlaneMapper = vtkDataSetMapper::New();
196   if (!aPolyData->GetOutput()->GetNumberOfCells()) {
197     onPreviewCheck(false);
198     return;
199   }
200   aPlaneMapper->SetInput(aPolyData->GetOutput());
201   aPlaneMapper->ScalarVisibilityOff();
202
203   myPreviewActor = SALOME_Actor::New();
204   myPreviewActor->PickableOff();
205   myPreviewActor->SetMapper(aPlaneMapper);
206   aPlaneMapper->Delete();
207   GET_VTK_VIEWFRAME(myStudy)->AddActor(myPreviewActor);
208 }
209
210
211
212 int VisuGUI_CutPlanesPane::storeToPrsObject(VISU::CutPlanes_i* thePrs) {
213   thePrs->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
214   thePrs->SetNbPlanes(getNbPlanes());
215   thePrs->SetDisplacement(myPosSpn->value());
216   for (int i = 0; i < getNbPlanes(); ++i) 
217     {
218       if (!((QCheckTableItem*)myPosTable->item(i, 1))->isChecked())
219         thePrs->SetPlanePosition( i, myPosTable->text(i, 0).toDouble());
220       else thePrs->SetDefault(i);
221     }
222   return 1;
223 }
224
225
226 /*!
227   Called when orientation is changed
228 */
229 void VisuGUI_CutPlanesPane::orientationChanged( int Id )
230 {
231   if ( Id == 0 ) { // RBxy->isChecked()
232     LabelRot1->setText( tr( "Rotation around X (Y to Z):" ) );
233     LabelRot2->setText( tr( "Rotation around Y (Z to X):" ) );
234   } else if ( Id == 1 ) { // RByz->isChecked()
235     LabelRot1->setText( tr( "Rotation around Y (Z to X):" ) );
236     LabelRot2->setText( tr( "Rotation around Z (X to Y):" ) );
237   } else { 
238     LabelRot1->setText( tr( "Rotation around Z (X to Y):" ) );
239     LabelRot2->setText( tr( "Rotation around X (Y to Z):" ) );
240   }
241   DrawTable();
242 }
243
244
245
246
247 /*!
248   Sets planes orientation and position
249 */
250 void VisuGUI_CutPlanesPane::setPlanePos( const VISU::CutPlanes::Orientation  orient)
251 {
252   if ( orient == VISU::CutPlanes::XY )           // xy
253     {
254       RBxy->setChecked( true );
255       orientationChanged( 0 );
256     }
257   else if ( orient == VISU::CutPlanes::YZ )       // yz
258     {
259       RByz->setChecked( true );
260       orientationChanged( 1 );
261     }
262   else                         // zx
263    {
264      RBzx->setChecked( true );
265      orientationChanged( 2 );
266    }
267   
268 }
269
270 /*!
271   Gets planes orientation
272 */
273 VISU::CutPlanes::Orientation VisuGUI_CutPlanesPane::getOrientaion()
274 {
275   VISU::CutPlanes::Orientation orient;
276   if ( RBxy->isChecked() )     // xy
277     orient = VISU::CutPlanes::XY;
278   else if ( RByz->isChecked() )     // yz
279     orient = VISU::CutPlanes::YZ;
280   else if ( RBzx->isChecked() )     // zx
281     orient = VISU::CutPlanes::ZX;
282   return orient;
283 }
284
285 /*!
286   Sets planes rotation
287 */
288 void VisuGUI_CutPlanesPane::setRotation( const double r1, const double r2 )
289 {
290   Rot1->setValue( r1 );
291   Rot2->setValue( r2 );
292 }
293
294 /*!
295   Draw the table of planes positions
296 */
297
298 void VisuGUI_CutPlanesPane::DrawTable()
299 {
300   if (myCutPlanes == NULL) return;
301   if (!hasInit) return;
302
303   int aNbRows = myPosTable->numRows();
304   int aNbPlanes = getNbPlanes();  
305
306   myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
307   myCutPlanes->SetNbPlanes(aNbPlanes);
308   myCutPlanes->SetDisplacement(myPosSpn->value());
309   if (aNbRows>0)
310     for (int i = 0; i < aNbRows; ++i) {
311       QCheckTableItem* aItem = (QCheckTableItem*)myPosTable->item( i, 1 );
312       if (aItem == 0) break;
313       if (!aItem->isChecked())
314         myCutPlanes->SetPlanePosition(i, myPosTable->text(i, 0).toDouble());
315     }
316   
317   if (aNbPlanes > aNbRows)
318     myPosTable->insertRows(aNbRows, aNbPlanes - aNbRows );
319   else if (aNbPlanes < aNbRows)
320     myPosTable->setNumRows(aNbPlanes);
321
322   int aMin = (aNbRows < aNbPlanes)? aNbRows : aNbPlanes;
323   for (int i = 0; i<aMin; i++) {
324     myPosTable->setText(i, 0, QString::number(myCutPlanes->GetPlanePosition(i)));
325     ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(myCutPlanes->IsDefault(i));
326   }
327
328   QHeader *vh = myPosTable->verticalHeader();
329   QString str("Plane# %1");
330   for (int i=aMin; i<aNbPlanes; i++) {
331     VisuGUI_NumEditItem* aEditItem = new VisuGUI_NumEditItem(myPosTable, 
332                                                              QTableItem::OnTyping, 
333                                                              QString::number(myCutPlanes->GetPlanePosition(i)));
334     aEditItem->setReplaceable(false);
335     aEditItem->setEnabled(!myCutPlanes->IsDefault(i));
336     myPosTable->setItem(i, 0, aEditItem);
337
338     QCheckTableItem* aCheck = new QCheckTableItem(myPosTable, 0);
339     aCheck->setChecked(myCutPlanes->IsDefault(i));
340     aCheck->setReplaceable(false);
341     myPosTable->setItem(i, 1, aCheck);
342     
343     vh->setLabel( i, str.arg(i+1) );
344   }
345
346   // Update preview
347   if (myPreviewCheck->isChecked()) {
348     if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
349       myCutPlanes->GetPL()->Update();
350       deletePlanes();
351       createPlanes();
352       vf->Repaint();
353     }
354   }
355 }
356
357 void VisuGUI_CutPlanesPane::setDefault(int all)
358 {
359   myPosTable->setCurrentCell(-1, 1);
360   myPosTable->clearSelection();
361   if (all == 0) return;
362   if (all == 1)
363     for (int i = 0; i < getNbPlanes(); ++i) 
364       ((QCheckTableItem*)myPosTable->item( i, 1 ))->setChecked(true);
365         
366   for (int i = 0; i < getNbPlanes(); ++i) {
367     if ( ((QCheckTableItem*)myPosTable->item( i, 1 ))->isChecked() ) {
368       myCutPlanes->SetDefault(i);
369       myPosTable->setText( i, 0, QString::number(myCutPlanes->GetPlanePosition(i)));
370       myPosTable->item( i, 0 )->setEnabled(false);
371     } else 
372       myPosTable->item( i, 0 )->setEnabled(true); 
373   }
374 }
375
376 void VisuGUI_CutPlanesPane::onValueChanged(int theRow, int theCol) {
377   if (theCol == 0) {
378     QString aTxt = myPosTable->text(theRow, 0);
379     bool isChanged = !aTxt.isEmpty();
380     ((QCheckTableItem*)myPosTable->item(theRow, 1))->setChecked(!isChanged);
381
382     if (myPreviewCheck->isChecked()) {
383       //Update Preview
384       if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
385         myCutPlanes->SetPlanePosition( theRow, aTxt.toDouble());
386         myCutPlanes->GetPL()->Update();
387         deletePlanes();
388         createPlanes();
389         vf->Repaint();
390       }
391     }
392   } else {
393     bool isDefault = ((QCheckTableItem*)myPosTable->item(theRow, theCol))->isChecked();
394     if (isDefault) {
395       myCutPlanes->SetDefault(theRow);
396       myPosTable->setText(theRow, 0, QString::number(myCutPlanes->GetPlanePosition(theRow)));
397
398       if (myPreviewCheck->isChecked()) {
399         if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
400           //Update Preview
401           myCutPlanes->GetPL()->Update();
402           deletePlanes();
403           createPlanes();
404           vf->Repaint();
405         }
406       }
407     }
408     myPosTable->item(theRow, 0)->setEnabled(!isDefault);
409   }
410 }
411
412
413 void VisuGUI_CutPlanesPane::deletePlanes() {
414   if (myPreviewActor == 0) return;
415   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy))
416     vf->RemoveActor(myPreviewActor);
417   myPreviewActor->Delete();
418   myPreviewActor = 0;
419 }
420
421 void VisuGUI_CutPlanesPane::onRotation(double theValue) {
422   if (myCutPlanes == NULL) return;
423   if (myPreviewCheck->isChecked()) {
424     if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
425       myCutPlanes->SetOrientation(getOrientaion(),getRotation1()*PI/180.,getRotation2()*PI/180.);
426       myCutPlanes->GetPL()->Update();
427       deletePlanes();
428       createPlanes();  
429       vf->Repaint();  
430     }
431   }
432 }
433
434
435 void VisuGUI_CutPlanesPane::onPreviewCheck(bool thePreview) {
436   if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
437     if (thePreview) {
438       storeToPrsObject(myCutPlanes);
439       myCutPlanes->GetPL()->Update();
440       createPlanes();
441       vf->onViewFitAll();
442     } else {
443       deletePlanes();
444       vf->Repaint();
445     }
446   }
447 }
448
449
450
451
452 //###################################################################
453
454
455
456 /*!
457   Constructor
458 */
459 VisuGUI_CutPlanesDlg::VisuGUI_CutPlanesDlg(bool theIsCreation, bool theIsModal)
460   : QDialog(  QAD_Application::getDesktop(), "VisuGUI_CutPlanesDlg", theIsModal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu/* | WDestructiveClose */),
461     myStudy(QAD_Application::getDesktop()->getActiveStudy())
462 {
463   myStudyFrame = myStudy -> getActiveStudyFrame();
464   if (!theIsModal) {
465     setWFlags(getWFlags() | WDestructiveClose);
466   }
467   setCaption( tr( "Cut Planes Definition" ) );
468   setSizeGripEnabled( TRUE );
469   myIsCreation = theIsCreation;
470
471   QVBoxLayout* TopLayout = new QVBoxLayout( this ); 
472   TopLayout->setSpacing( 6 );
473   TopLayout->setMargin( 11 );
474  
475   QTabWidget* aTabBox = new QTabWidget(this);
476   myCutPane = new  VisuGUI_CutPlanesPane(this, myStudy);
477   aTabBox->addTab(myCutPane, "Cut Planes");
478   myScalarPane = new VisuGUI_ScalarBarPane(this, false);
479   myScalarPane->setMargin( 5 );
480   aTabBox->addTab(myScalarPane, "Scalar Bar");
481
482   TopLayout->addWidget(aTabBox);
483
484   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
485   GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
486   GroupButtons->setTitle( tr( ""  ) );
487   GroupButtons->setColumnLayout(0, Qt::Vertical );
488   GroupButtons->layout()->setSpacing( 0 );
489   GroupButtons->layout()->setMargin( 0 );
490   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
491   GroupButtonsLayout->setAlignment( Qt::AlignTop );
492   GroupButtonsLayout->setSpacing( 6 );
493   GroupButtonsLayout->setMargin( 11 );
494
495   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
496   buttonOk->setAutoDefault( TRUE );
497   buttonOk->setDefault( TRUE );
498   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
499   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1 );
500
501   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ), GroupButtons, "buttonCancel" );
502   buttonCancel->setAutoDefault( TRUE );
503   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
504
505   TopLayout->addWidget(GroupButtons);
506
507   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
508   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
509   connect( myStudy, SIGNAL(closed()), this, SLOT( reject() ) );
510   connect( myStudyFrame, SIGNAL(sfStudyFrameActivated(QAD_StudyFrame*)), this, SLOT(onFrameActivated(QAD_StudyFrame*)));
511 }
512
513
514 void VisuGUI_CutPlanesDlg::accept() {
515   if (myScalarPane->check()) {
516     if (!isModal()) {
517       if (storeToPrsObject(myPrs)) {
518         if (myIsCreation) { 
519           if (myStudy->getActiveStudyFrame()->getTypeView() == VIEW_VTK) {
520             try {
521             visuGUI->CreateActor(myPrs);
522             }
523             catch (...) {
524               reject();
525               return;
526             }
527             GET_VTK_VIEWFRAME(myStudy)->onViewFitAll(); 
528           }
529         } else {
530           visuGUI->RecreateActor(myPrs);
531           if (VTKViewer_ViewFrame* vf = GET_VTK_VIEWFRAME(myStudy)) {
532             if ( vf->getRenderer()->GetActors()->GetNumberOfItems () > 0 ) {
533               vf->getRenderer()->ResetCameraClippingRange();
534               vf->Repaint();
535             }
536           }
537         }
538       } else {
539         if (myIsCreation) {
540           visuGUI->DeletePresentation(myPrs);
541         }
542       }
543     }
544     QDialog::accept();
545   }
546 }
547
548 void VisuGUI_CutPlanesDlg::reject() {
549   if (myIsCreation && (!isModal())) {
550     visuGUI->DeletePresentation(myPrs);
551     myStudy -> updateObjBrowser();
552   }
553   QDialog::reject();
554 }
555
556 void VisuGUI_CutPlanesDlg::onFrameActivated( QAD_StudyFrame* theFrame) {
557   if (theFrame != myStudyFrame) 
558     reject();
559 }
560
561 //###################################################################
562
563
564
565 QWidget* VisuGUI_NumEditItem::createEditor() const 
566 {
567   QLineEdit *editline = new QLineEdit(text(), table()->viewport());
568   QDoubleValidator *dvalidator = new QDoubleValidator(table()->viewport());
569   dvalidator->setDecimals(32);
570   editline->setValidator(dvalidator);
571   return editline;
572 }