Salome HOME
untabify
[modules/visu.git] / src / VISUGUI / VisuGUI_Plot3DDlg.cxx
1 //  Copyright (C) 2007-2008  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  Copyright (C) 2003-2007  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.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  VISU VISUGUI : GUI of VISU component
23 //  File   : VisuGUI_Plot3DDlg.cxx
24 //  Author : Laurent CORNABE & Hubert ROLLAND
25 //  Module : VISU
26 //  $Header$
27 //
28 #include "VisuGUI_Plot3DDlg.h"
29
30 #include "VisuGUI.h"
31 #include "VisuGUI_Tools.h"
32 #include "VisuGUI_ViewTools.h"
33 #include "VisuGUI_InputPane.h"
34
35 #include "VISU_ColoredPrs3dFactory.hh"
36 #include "VISU_ViewManager_i.hh"
37 #include "VISU_Plot3DPL.hxx"
38
39 #include "SVTK_ViewWindow.h"
40
41 #include "SALOME_Actor.h"
42 #include "SUIT_Desktop.h"
43 #include "SUIT_Session.h"
44 #include "SUIT_MessageBox.h"
45 #include "SUIT_ResourceMgr.h"
46 #include "LightApp_Application.h"
47
48 #include "QtxDoubleSpinBox.h"
49
50 #include <QLayout>
51 #include <QValidator>
52 #include <QTabWidget>
53 #include <QRadioButton>
54 #include <QSpinBox>
55 #include <QCheckBox>
56 #include <QVBoxLayout>
57 #include <QHBoxLayout>
58 #include <QKeyEvent>
59 #include <QButtonGroup>
60 #include <QGroupBox>
61 #include <QLabel>
62 #include <QPushButton>
63
64 #include <vtkUnstructuredGrid.h>
65 #include <vtkDataSetMapper.h>
66 #include <vtkRenderer.h>
67 #include <vtkPlaneSource.h>
68 #include <vtkPolyData.h>
69 #include <vtkMath.h>
70
71 using namespace std;
72
73 #define SURFACE_PRS_ID 0
74 #define CONTOUR_PRS_ID 1
75
76 //=======================================================================
77 //function : renderViewFrame
78 //purpose  :
79 //=======================================================================
80 static void renderViewFrame (SVTK_ViewWindow* vw)
81 {
82   if (vw) {
83 //    vw->getRenderer()->ResetCameraClippingRange();
84     vw->Repaint();
85   }
86 }
87
88 //=======================================================================
89 //class    : TPlane
90 //purpose  : actor of plane preview
91 //=======================================================================
92 class TPlane : public SALOME_Actor
93 {
94   vtkFloatingPointType mySize;
95   vtkDataSetMapper*    myMapper;
96   vtkPlaneSource*      myPlaneSource;
97
98  public:
99   // constructor
100   TPlane(vtkFloatingPointType planeSize): mySize(planeSize)
101   {
102     Init();
103   }
104   // set plane parameters
105   void Set(vtkFloatingPointType origin[3], vtkFloatingPointType normal[3])
106   {
107     vtkFloatingPointType point2[3], point1[3];
108     vtkMath::Perpendiculars(normal, point1, point2, 0.);
109     for (int i = 0; i < 3; ++i) {
110       point1[ i ] = point1[ i ] * mySize + origin[ i ];
111       point2[ i ] = point2[ i ] * mySize + origin[ i ];
112     }
113     myPlaneSource->SetOrigin(origin);
114     myPlaneSource->SetPoint1(point1);
115     myPlaneSource->SetPoint2(point2);
116     myPlaneSource->SetCenter(origin);
117   }
118   vtkTypeMacro(TPlane,SALOME_Actor);
119
120  protected:
121   void Init() {
122     myPlaneSource = vtkPlaneSource::New();
123     myMapper = vtkDataSetMapper::New();
124     myMapper->SetInput(myPlaneSource->GetOutput());
125     // actor methods
126     VisibilityOff();
127     PickableOff();
128     SetInfinitive(true);
129     SetOpacity(0.85);
130     SetMapper(myMapper);
131   }
132   ~TPlane() {
133     myMapper->RemoveAllInputs();
134     myMapper->Delete();
135     // commented: porting to vtk 5.0
136     //myPlaneSource->UnRegisterAllOutputs();
137     myPlaneSource->Delete();
138   };
139   // Not implemented.
140   TPlane(const TPlane&);
141   void operator=(const TPlane&);
142 };
143
144 //=======================================================================
145 //function : VisuGUI_Plot3DPane
146 //purpose  :
147 //=======================================================================
148 VisuGUI_Plot3DPane::VisuGUI_Plot3DPane (QWidget* parent)
149      : QWidget(parent), myInitFromPrs(false), myPreviewActor(NULL),
150        myViewWindow(VISU::GetActiveViewWindow<SVTK_ViewWindow>()), myPrs(NULL), myPipeCopy(NULL)
151 {
152   QVBoxLayout* aMainLay = new QVBoxLayout( this );
153   aMainLay->setAlignment(Qt::AlignTop);
154   aMainLay->setSpacing(6);
155
156   // Orientation
157
158   GBOrientation = new QButtonGroup ( this );
159   GBoxOrient = new QGroupBox(tr("ORIENTATION"),this);
160   aMainLay->addWidget(GBoxOrient);
161   
162   //GBOrientation->setColumnLayout(0, Qt::Vertical);
163   //GBOrientation->layout()->setSpacing(0);
164   //GBOrientation->layout()->setMargin(0);
165   QGridLayout* BGOrientationLayout = new QGridLayout (GBoxOrient);
166   BGOrientationLayout->setAlignment(Qt::AlignTop);
167   BGOrientationLayout->setSpacing(6);
168   BGOrientationLayout->setMargin(11);
169
170   QRadioButton *RBxy, *RByz, *RBzx;
171   RBxy = new QRadioButton (tr("// X-Y"), GBoxOrient );
172   RByz = new QRadioButton (tr("// Y-Z"), GBoxOrient );
173   RBzx = new QRadioButton (tr("// Z-X"), GBoxOrient );
174   BGOrientationLayout->addWidget(RBxy, 0, 0);
175   BGOrientationLayout->addWidget(RByz, 0, 1);
176   BGOrientationLayout->addWidget(RBzx, 0, 2);
177
178   GBOrientation->addButton( RBxy, 0 );
179   GBOrientation->addButton( RByz, 1 );
180   GBOrientation->addButton( RBzx, 2 );
181
182   // Rotation
183
184   QGroupBox* GBrot = new QGroupBox (tr("ROTATIONS"), this);
185   aMainLay->addWidget( GBrot );
186   //GBrot->setColumnLayout(0, Qt::Vertical);
187   //GBrot->layout()->setSpacing(0);
188   //GBrot->layout()->setMargin(0);
189   QGridLayout* GBrotLayout = new QGridLayout (GBrot);
190   GBrotLayout->setAlignment(Qt::AlignTop);
191   GBrotLayout->setSpacing(6);
192   GBrotLayout->setMargin(11);
193   // label 1
194   LabelRot1 = new QLabel (tr("ROTATION_X"), GBrot );
195   GBrotLayout->addWidget(LabelRot1, 0, 0);
196   // spin 1
197   Rot1 = new QtxDoubleSpinBox (-180, 180, 5, GBrot);
198   Rot1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
199   GBrotLayout->addWidget(Rot1, 0, 1);
200   // label 2
201   LabelRot2 = new QLabel (tr("ROTATION_Y"), GBrot);
202   GBrotLayout->addWidget(LabelRot2, 1, 0);
203   // spin 2
204   Rot2 = new QtxDoubleSpinBox (-180, 180, 5, GBrot);
205   Rot2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
206   GBrotLayout->addWidget(Rot2, 1, 1);
207
208   // Position
209
210   QGroupBox* GBpos = new QGroupBox (tr("POSITION"), this);
211   aMainLay->addWidget( GBpos );
212   //GBpos->setColumnLayout(0, Qt::Horizontal);
213   //GBpos->layout()->setSpacing(0);
214   //GBpos->layout()->setMargin(0);
215   QGridLayout* GBposLayout = new QGridLayout (GBpos);
216   GBposLayout->setAlignment(Qt::AlignTop);
217   GBposLayout->setSpacing(6);
218   GBposLayout->setMargin(11);
219   // value label
220   QLabel * valueLabel = new QLabel (tr("POSITION_VALUE"), GBpos);
221   GBposLayout->addWidget(valueLabel, 0, 0);
222   // value spin
223   PositionSpn = new QtxDoubleSpinBox (0, 1, 0.1, GBpos);
224   GBposLayout->addWidget(PositionSpn, 0, 1);
225   // Relative CheckBox
226   RelativeChkB = new QCheckBox (tr("RELATIVE"), GBpos);
227   RelativeChkB->setChecked(true);
228   GBposLayout->addWidget(RelativeChkB, 0, 2);
229
230   // Scale, Presentation type, Nb Contours, Preview
231
232   QFrame* bottomFrame = new QFrame (this);
233   aMainLay->addWidget( bottomFrame );
234   QGridLayout* bottomLayout = new QGridLayout (bottomFrame);
235   bottomLayout->setAlignment(Qt::AlignTop);
236   bottomLayout->setSpacing(11);
237   bottomLayout->setMargin(0);
238   // scale
239   QLabel* scaleLabel = new QLabel (tr("SCALE"), bottomFrame);
240   SUIT_ResourceMgr* aResourceMgr = VISU::GetResourceMgr();
241   int aPrecision = aResourceMgr->integerValue( "VISU", "floating_point_precision", 0 );
242   ScaleSpn = new QtxDoubleSpinBox (-1.e38, 1.e38, 0.1, aPrecision*(-1), 38, bottomFrame);
243   // Presentation type
244   GBPrsType = new QButtonGroup ( bottomFrame);
245   QGroupBox* aGB = new QGroupBox (tr("PRESENTATION_TYPE"), bottomFrame);
246   QHBoxLayout* aHBoxLay = new QHBoxLayout( aGB );
247   
248   QRadioButton* aRB = new QRadioButton (tr("SURFACE"), aGB);
249   aHBoxLay->addWidget( aRB );
250   GBPrsType->addButton( aRB, 0 );
251   aRB = new QRadioButton (tr("CONTOUR"), aGB);
252   aHBoxLay->addWidget( aRB );
253   GBPrsType->addButton( aRB, 1 );
254   // nb Contours
255   QLabel* nbContLabel = new QLabel (tr("NUMBER_CONTOURS"), bottomFrame);
256   NbContoursSpn = new QSpinBox ( bottomFrame );
257   NbContoursSpn->setMinimum( 1 );
258   NbContoursSpn->setMaximum( 999 );
259   NbContoursSpn->setSingleStep( 1 );
260   
261   // Preview
262   PreviewChkB = new QCheckBox (tr("PREVIEW"), bottomFrame);
263   PreviewChkB->setChecked(false);
264
265   bottomLayout->addWidget(scaleLabel,    0, 0);
266   bottomLayout->addWidget(ScaleSpn,      0, 1);
267   bottomLayout->addWidget(aGB, 1, 0, 1, 2);
268   bottomLayout->addWidget(nbContLabel,   2, 0);
269   bottomLayout->addWidget(NbContoursSpn, 2, 1);
270   bottomLayout->addWidget(PreviewChkB,   3, 0);
271
272   // signals and slots connections
273   connect(GBOrientation, SIGNAL(buttonClicked(int)),   this, SLOT(orientationChanged(int)));
274   connect(Rot1,          SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
275   connect(Rot2,          SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
276   connect(PositionSpn,   SIGNAL(valueChanged(double)), this, SLOT(onPositionSpn()));
277   connect(RelativeChkB,  SIGNAL(toggled(bool)),        this, SLOT(onRelativePos(bool)));
278   connect(GBPrsType,     SIGNAL(buttonClicked(int)),   this, SLOT(onPrsType(int)));
279   connect(PreviewChkB,   SIGNAL(toggled(bool)),        this, SLOT(updatePreview()));
280 }
281
282 //=======================================================================
283 //function : destructor
284 //purpose  :
285 //=======================================================================
286 VisuGUI_Plot3DPane::~VisuGUI_Plot3DPane()
287 {}
288
289 //=======================================================================
290 //function : storePrsParams
291 //purpose  : create a copy of Prs parameters and then store current
292 //           control values into the Prs
293 //=======================================================================
294 void VisuGUI_Plot3DPane::storePrsParams()
295 {
296   if (!myPipeCopy)
297     myPipeCopy = VISU_Plot3DPL::New();
298   if (myPrs) {
299     myPipeCopy->ShallowCopy(myPrs->GetPipeLine(), true);
300     storeToPrsObject(myPrs);
301   }
302 }
303
304 //=======================================================================
305 //function : restorePrsParams
306 //purpose  : restore Prs parameters from the copy
307 //=======================================================================
308 void VisuGUI_Plot3DPane::restorePrsParams()
309 {
310   if (!myPipeCopy)
311     myPipeCopy = VISU_Plot3DPL::New();
312   if (myPrs)
313     myPrs->GetPipeLine()->ShallowCopy(myPipeCopy, false);
314 }
315
316 //=======================================================================
317 //function : onPositionSpn
318 //purpose  : update absolute position range
319 //=======================================================================
320 void VisuGUI_Plot3DPane::onPositionSpn()
321 {
322   if (myPrs && !RelativeChkB->isChecked()) {
323     vtkFloatingPointType minPos, maxPos;
324     storePrsParams();
325     myPrs->GetSpecificPL()->GetMinMaxPosition(minPos, maxPos);
326     restorePrsParams();
327     if (minPos > PositionSpn->value())
328       minPos = PositionSpn->value();
329     if (maxPos < PositionSpn->value())
330       maxPos = PositionSpn->value();
331     PositionSpn->setRange(minPos, maxPos);
332   }
333   updatePreview();
334 }
335
336 //=======================================================================
337 //function : orientationChanged
338 //purpose  : update rotation labels and preview
339 //=======================================================================
340 void VisuGUI_Plot3DPane::orientationChanged(int Id)
341 {
342   if (Id == 0) { // RBxy->isChecked()
343     LabelRot1->setText(tr("ROTATION_X"));
344     LabelRot2->setText(tr("ROTATION_Y"));
345   } else if (Id == 1) { // RByz->isChecked()
346     LabelRot1->setText(tr("ROTATION_Y"));
347     LabelRot2->setText(tr("ROTATION_Z"));
348   } else {
349     LabelRot1->setText(tr("ROTATION_Z"));
350     LabelRot2->setText(tr("ROTATION_X"));
351   }
352   updatePreview();
353 }
354
355 //=======================================================================
356 //function : onRelativePos
357 //purpose  : update position value and range
358 //=======================================================================
359 void VisuGUI_Plot3DPane::onRelativePos(bool isRelativePos)
360 {
361   vtkFloatingPointType minPos = 0., maxPos = 1., pos = PositionSpn->value();
362   if (myPrs) {
363     storePrsParams();
364     myPrs->GetSpecificPL()->GetMinMaxPosition(minPos, maxPos);
365     restorePrsParams();
366     if (-1e-7 < (maxPos - minPos) && (maxPos - minPos) < 1e-7) {
367       pos = 0;
368     } else {
369       if (isRelativePos) // absolute -> relative
370         pos = (pos - minPos) / (maxPos - minPos);
371       else  // relative -> absolute
372         pos = minPos * (1. - pos) + maxPos * pos;
373     }
374   }
375   if (isRelativePos) {
376     minPos = 0.;
377     maxPos = 1.;
378   }
379   PositionSpn->setMinimum(minPos);
380   PositionSpn->setMaximum(maxPos);
381   PositionSpn->setSingleStep((maxPos - minPos) / 10.);
382   PositionSpn->setValue(pos);
383 }
384
385 //=======================================================================
386 //function : onPrsType
387 //purpose  :
388 //=======================================================================
389 void VisuGUI_Plot3DPane::onPrsType(int id)
390 {
391   NbContoursSpn->setEnabled(id == CONTOUR_PRS_ID);
392 }
393
394 //=======================================================================
395 //function : updatePreview
396 //purpose  :
397 //=======================================================================
398 void VisuGUI_Plot3DPane::updatePreview()
399 {
400   if(myPreviewActor){
401     vtkRenderer* aRend       = myPreviewActor->GetRenderer();
402     vtkRenderWindow* aWnd = aRend->GetRenderWindow();
403     if (!aWnd) return;
404   }
405  if (myInitFromPrs || !myPrs || !myViewWindow)
406     return;
407   bool fitall = false;
408   if (PreviewChkB->isChecked()) // place preview plane
409   {
410     // get plane preview actor
411     TPlane* planePreview = (TPlane*) myPreviewActor;
412     if (!planePreview) {
413       myPreviewActor = planePreview = new TPlane(myPrs->GetInput()->GetLength());
414       myViewWindow->AddActor(planePreview);
415       fitall = !VISU::FindActor(myViewWindow, myPrs);
416     }
417     // set plane parameters corresponding to control values
418     storePrsParams();
419     vtkFloatingPointType normal[3], origin[3];
420     myPrs->GetSpecificPL()->GetBasePlane(origin, normal, true);
421     planePreview->Set(origin, normal);
422     restorePrsParams();
423   }
424   if (myPreviewActor)
425     myPreviewActor->SetVisibility(PreviewChkB->isChecked());
426
427   renderViewFrame(myViewWindow);
428
429   if (fitall && VISU::GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)) {
430     myPreviewActor->SetInfinitive(false);
431     myViewWindow->onFitAll();
432     myPreviewActor->SetInfinitive(true);
433   }
434 }
435
436 //=======================================================================
437 //function : initFromPrsObject
438 //purpose  :
439 //=======================================================================
440 void VisuGUI_Plot3DPane::initFromPrsObject(VISU::Plot3D_i* thePrs)
441 {
442   myInitFromPrs = true;
443   myPrs = thePrs;
444
445   // orientation
446   int id;
447   switch (thePrs->GetOrientationType()) {
448   case VISU::Plot3D::XY: id = 0; break;
449   case VISU::Plot3D::YZ: id = 1; break;
450   default: id = 2;
451   }
452   GBOrientation->button(id)->click();
453
454   // rotation
455   Rot1->setValue(thePrs->GetRotateX() * 180./PI);
456   Rot2->setValue(thePrs->GetRotateY() * 180./PI);
457
458   // position
459   RelativeChkB->setChecked(thePrs->IsPositionRelative());
460   onRelativePos(thePrs->IsPositionRelative()); // update range
461   PositionSpn->setValue(thePrs->GetPlanePosition());
462
463   // scale
464   ScaleSpn->setValue(thePrs->GetScaleFactor());
465
466   // prs type
467   id = thePrs->GetIsContourPrs() ? CONTOUR_PRS_ID : SURFACE_PRS_ID;
468   GBPrsType->button(id)->click();
469
470   // nb contours
471   NbContoursSpn->setValue(thePrs->GetNbOfContours());
472
473   // disable cutting plane controls if the mesh is planar
474
475   if (thePrs->GetPipeLine()->IsPlanarInput())
476   {
477     //GBOrientation->setEnabled(false);
478     GBoxOrient->setEnabled(false);
479     Rot1         ->setEnabled(false);
480     Rot2         ->setEnabled(false);
481     PositionSpn  ->setEnabled(false);
482     RelativeChkB ->setEnabled(false);
483     PreviewChkB  ->setEnabled(false);
484   }
485
486   myInitFromPrs = false;
487   updatePreview();
488 }
489
490 //=======================================================================
491 //function : storeToPrsObject
492 //purpose  :
493 //=======================================================================
494 int VisuGUI_Plot3DPane::storeToPrsObject(VISU::Plot3D_i* thePrs)
495 {
496   if (myInitFromPrs)
497     return 0;
498   // orientation
499   int id = GBOrientation->id (GBOrientation->checkedButton());
500   VISU::Plot3D::Orientation ori;
501   switch (id) {
502   case 0 : ori = VISU::Plot3D::XY; break;
503   case 1 : ori = VISU::Plot3D::YZ; break;
504   default: ori = VISU::Plot3D::ZX;
505   }
506   // rotation
507   thePrs->SetOrientation(ori, Rot1->value()*PI/180., Rot2->value()*PI/180.);
508
509   // position
510   thePrs->SetPlanePosition(PositionSpn->value(), RelativeChkB->isChecked());
511
512   // scale
513   thePrs->SetScaleFactor(ScaleSpn->value());
514
515   // prs type
516   id = GBPrsType->id (GBPrsType->checkedButton());
517   thePrs->SetContourPrs(id == CONTOUR_PRS_ID);
518
519   // nb contours
520   thePrs->SetNbOfContours(NbContoursSpn->value());
521
522   return 1;
523 }
524
525 //=======================================================================
526 //function : check
527 //purpose  :
528 //=======================================================================
529 bool VisuGUI_Plot3DPane::check()
530 {
531   if(!myPreviewActor) return true;
532   
533   vtkRenderer* aRend    = myPreviewActor->GetRenderer();
534   vtkRenderWindow* aWnd = aRend->GetRenderWindow();
535   if(aRend && aWnd){
536     myPreviewActor->SetVisibility(false);
537     myViewWindow->RemoveActor(myPreviewActor);
538     myPreviewActor->Delete();
539     myPreviewActor = 0;
540   }
541     
542   return true;
543 }
544
545 void VisuGUI_Plot3DPane::setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos)
546 {
547   // Set plane
548   int id;
549   switch (theOrientation) {
550   case VISU::Plot3D::XY: id = 0; break;
551   case VISU::Plot3D::YZ: id = 1; break;
552   default: id = 2;
553   }
554   GBOrientation->button(id)->click();
555   GBoxOrient->setEnabled(false);
556
557
558   // Set rotation
559   Rot1->setValue(theXRotation * 180./PI);
560   Rot1->setEnabled(false);
561   Rot2->setValue(theYRotation * 180./PI);
562   Rot2->setEnabled(false);
563
564   // Set position
565   RelativeChkB->setChecked(false);
566   onRelativePos(false); // update range
567   PositionSpn->setValue(thePlanePos);
568   RelativeChkB->setEnabled(false);
569   PositionSpn->setEnabled(false);
570 }
571
572
573 //=======================================================================
574 //function : Constructor
575 //purpose  :
576 //=======================================================================
577 VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg (SalomeApp_Module* theModule)
578   : VisuGUI_ScalarBarBaseDlg(theModule)
579 {
580   setWindowTitle(tr("TITLE"));
581   setSizeGripEnabled(TRUE);
582
583   QVBoxLayout* TopLayout = new QVBoxLayout(this);
584   TopLayout->setSpacing(6);
585   TopLayout->setMargin(11);
586
587   myTabBox = new QTabWidget (this);
588   myIsoPane = new VisuGUI_Plot3DPane (this);
589   if ( myIsoPane->layout()  )
590     myIsoPane->layout()->setMargin(5);
591   myTabBox->addTab(myIsoPane, tr("PLOT3D_TAB_TITLE"));
592   myInputPane = new VisuGUI_InputPane(VISU::TPLOT3D, theModule, this);
593   myTabBox->addTab(GetScalarPane(), tr("SCALAR_BAR_TAB_TITLE"));
594   myTabBox->addTab(myInputPane, tr("INPUT_TAB_TITLE"));
595
596   TopLayout->addWidget(myTabBox);
597
598   QGroupBox* GroupButtons = new QGroupBox (this );
599   GroupButtons->setGeometry(QRect(10, 10, 281, 48));
600   //GroupButtons->setColumnLayout(0, Qt::Vertical);
601   //GroupButtons->layout()->setSpacing(0);
602   //GroupButtons->layout()->setMargin(0);
603   QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons);
604   GroupButtonsLayout->setAlignment(Qt::AlignTop);
605   GroupButtonsLayout->setSpacing(6);
606   GroupButtonsLayout->setMargin(11);
607
608   QPushButton* buttonOk = new QPushButton (tr("BUT_OK"), GroupButtons);
609   buttonOk->setAutoDefault(TRUE);
610   buttonOk->setDefault(TRUE);
611   GroupButtonsLayout->addWidget(buttonOk, 0, 0);
612   GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
613   QPushButton* buttonCancel = new QPushButton (tr("BUT_CANCEL") , GroupButtons);
614   buttonCancel->setAutoDefault(TRUE);
615   GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
616   QPushButton* buttonHelp = new QPushButton (tr("BUT_HELP") , GroupButtons);
617   buttonHelp->setAutoDefault(TRUE);
618   GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
619
620   TopLayout->addWidget(GroupButtons);
621
622   // signals and slots connections
623   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
624   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
625   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(onHelp()));
626 }
627
628 VisuGUI_Plot3DDlg::~VisuGUI_Plot3DDlg()
629 {}
630
631 //=======================================================================
632 //function : accept
633 //purpose  :
634 //=======================================================================
635 void VisuGUI_Plot3DDlg::accept()
636 {
637   if (myIsoPane->check() && GetScalarPane()->check())
638     VisuGUI_ScalarBarBaseDlg::accept();
639 }
640
641 //=======================================================================
642 //function : reject
643 //purpose  :
644 //=======================================================================
645 void VisuGUI_Plot3DDlg::reject()
646 {
647   VisuGUI_ScalarBarBaseDlg::reject();
648 }
649
650 //=======================================================================
651 //function : initFromPrsObject
652 //purpose  :
653 //=======================================================================
654 void VisuGUI_Plot3DDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, 
655                                            bool theInit )
656 {
657   if( theInit )
658     myPrsCopy = VISU::TSameAsFactory<VISU::TPLOT3D>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
659
660   VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
661
662   myIsoPane->initFromPrsObject(myPrsCopy);
663
664   if( !theInit )
665     return;
666
667   myInputPane->initFromPrsObject( myPrsCopy );
668   myTabBox->setCurrentIndex( 0 );
669 }
670
671 //=======================================================================
672 //function : storeToPrsObject
673 //purpose  :
674 //=======================================================================
675 int VisuGUI_Plot3DDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
676 {
677   if(!myInputPane->check() || !GetScalarPane()->check())
678     return 0;
679   
680   int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
681   anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
682   anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy );
683
684   VISU::TSameAsFactory<VISU::TPLOT3D>().Copy(myPrsCopy, thePrs);
685
686   return anIsOk;
687 }
688
689 //=======================================================================
690 //function : onHelp
691 //purpose  :
692 //=======================================================================
693 QString VisuGUI_Plot3DDlg::GetContextHelpFilePath()
694 {
695   return "plot_3d_page.html";
696 }
697
698 //=======================================================================
699 //function : setPlane
700 //purpose  :
701 //=======================================================================
702 void VisuGUI_Plot3DDlg::setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos)
703 {
704   myIsoPane->setPlane(theOrientation, theXRotation, theYRotation, thePlanePos);
705 }