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