Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / VISUGUI / VisuGUI_Plot3DDlg.cxx
1 //  Copyright (C) 2007-2010  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 //  $Header$
28 //
29 #include "VisuGUI_Plot3DDlg.h"
30
31 #include "VisuGUI.h"
32 #include "VisuGUI_Tools.h"
33 #include "VisuGUI_ViewTools.h"
34 #include "VisuGUI_InputPane.h"
35
36 #include "VISU_ColoredPrs3dFactory.hh"
37 #include "VISU_ViewManager_i.hh"
38 #include "VISU_Plot3DPL.hxx"
39
40 #include "SVTK_ViewWindow.h"
41
42 #include "SALOME_Actor.h"
43 #include "SUIT_Desktop.h"
44 #include "SUIT_Session.h"
45 #include "SUIT_MessageBox.h"
46 #include "SUIT_ResourceMgr.h"
47 #include "LightApp_Application.h"
48 #include <SalomeApp_IntSpinBox.h>
49 #include <SalomeApp_DoubleSpinBox.h>
50
51 #include <QLayout>
52 #include <QValidator>
53 #include <QTabWidget>
54 #include <QRadioButton>
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 SalomeApp_DoubleSpinBox (GBrot);
198   VISU::initSpinBox( Rot1, -180, 180, 5, "angle_precision" );
199   Rot1->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
200   GBrotLayout->addWidget(Rot1, 0, 1);
201   // label 2
202   LabelRot2 = new QLabel (tr("ROTATION_Y"), GBrot);
203   GBrotLayout->addWidget(LabelRot2, 1, 0);
204   // spin 2
205   Rot2 = new SalomeApp_DoubleSpinBox (GBrot);
206   VISU::initSpinBox( Rot2, -180, 180, 5, "angle_precision" );  
207   Rot2->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
208   GBrotLayout->addWidget(Rot2, 1, 1);
209
210   // Position
211
212   QGroupBox* GBpos = new QGroupBox (tr("POSITION"), this);
213   aMainLay->addWidget( GBpos );
214   //GBpos->setColumnLayout(0, Qt::Horizontal);
215   //GBpos->layout()->setSpacing(0);
216   //GBpos->layout()->setMargin(0);
217   QGridLayout* GBposLayout = new QGridLayout (GBpos);
218   GBposLayout->setAlignment(Qt::AlignTop);
219   GBposLayout->setSpacing(6);
220   GBposLayout->setMargin(11);
221   // value label
222   QLabel * valueLabel = new QLabel (tr("POSITION_VALUE"), GBpos);
223   GBposLayout->addWidget(valueLabel, 0, 0);
224   // value spin
225   PositionSpn = new SalomeApp_DoubleSpinBox (GBpos);
226   VISU::initSpinBox( PositionSpn, 0, 1, 0.1, "parametric_precision" );
227   GBposLayout->addWidget(PositionSpn, 0, 1);
228   // Relative CheckBox
229   RelativeChkB = new QCheckBox (tr("RELATIVE"), GBpos);
230   RelativeChkB->setChecked(true);
231   GBposLayout->addWidget(RelativeChkB, 0, 2);
232
233   // Scale, Presentation type, Nb Contours, Preview
234
235   QFrame* bottomFrame = new QFrame (this);
236   aMainLay->addWidget( bottomFrame );
237   QGridLayout* bottomLayout = new QGridLayout (bottomFrame);
238   bottomLayout->setAlignment(Qt::AlignTop);
239   bottomLayout->setSpacing(11);
240   bottomLayout->setMargin(0);
241   // scale
242   QLabel* scaleLabel = new QLabel (tr("SCALE"), bottomFrame);
243   ScaleSpn = new SalomeApp_DoubleSpinBox (bottomFrame);
244   VISU::initSpinBox( ScaleSpn, -1.e38, 1.e38, 0.1, "visual_data_precision" );  
245   // Presentation type
246   GBPrsType = new QButtonGroup ( bottomFrame);
247   QGroupBox* aGB = new QGroupBox (tr("PRESENTATION_TYPE"), bottomFrame);
248   QHBoxLayout* aHBoxLay = new QHBoxLayout( aGB );
249   
250   QRadioButton* aRB = new QRadioButton (tr("SURFACE"), aGB);
251   aHBoxLay->addWidget( aRB );
252   GBPrsType->addButton( aRB, 0 );
253   aRB = new QRadioButton (tr("CONTOUR"), aGB);
254   aHBoxLay->addWidget( aRB );
255   GBPrsType->addButton( aRB, 1 );
256   // nb Contours
257   QLabel* nbContLabel = new QLabel (tr("NUMBER_CONTOURS"), bottomFrame);
258   NbContoursSpn = new SalomeApp_IntSpinBox ( bottomFrame );
259   NbContoursSpn->setAcceptNames( false );
260   NbContoursSpn->setMinimum( 1 );
261   NbContoursSpn->setMaximum( 999 );
262   NbContoursSpn->setSingleStep( 1 );
263   
264   // Preview
265   PreviewChkB = new QCheckBox (tr("PREVIEW"), bottomFrame);
266   PreviewChkB->setChecked(false);
267
268   bottomLayout->addWidget(scaleLabel,    0, 0);
269   bottomLayout->addWidget(ScaleSpn,      0, 1);
270   bottomLayout->addWidget(aGB, 1, 0, 1, 2);
271   bottomLayout->addWidget(nbContLabel,   2, 0);
272   bottomLayout->addWidget(NbContoursSpn, 2, 1);
273   bottomLayout->addWidget(PreviewChkB,   3, 0);
274
275   // signals and slots connections
276   connect(GBOrientation, SIGNAL(buttonClicked(int)),   this, SLOT(orientationChanged(int)));
277   connect(Rot1,          SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
278   connect(Rot2,          SIGNAL(valueChanged(double)), this, SLOT(updatePreview()));
279   connect(PositionSpn,   SIGNAL(valueChanged(double)), this, SLOT(onPositionSpn()));
280   connect(RelativeChkB,  SIGNAL(toggled(bool)),        this, SLOT(onRelativePos(bool)));
281   connect(GBPrsType,     SIGNAL(buttonClicked(int)),   this, SLOT(onPrsType(int)));
282   connect(PreviewChkB,   SIGNAL(toggled(bool)),        this, SLOT(updatePreview()));
283 }
284
285 //=======================================================================
286 //function : destructor
287 //purpose  :
288 //=======================================================================
289 VisuGUI_Plot3DPane::~VisuGUI_Plot3DPane()
290 {}
291
292 //=======================================================================
293 //function : storePrsParams
294 //purpose  : create a copy of Prs parameters and then store current
295 //           control values into the Prs
296 //=======================================================================
297 void VisuGUI_Plot3DPane::storePrsParams()
298 {
299   if (!myPipeCopy)
300     myPipeCopy = VISU_Plot3DPL::New();
301   if (myPrs) {
302     myPipeCopy->ShallowCopy(myPrs->GetPipeLine(), true);
303     storeToPrsObject(myPrs);
304   }
305 }
306
307 //=======================================================================
308 //function : restorePrsParams
309 //purpose  : restore Prs parameters from the copy
310 //=======================================================================
311 void VisuGUI_Plot3DPane::restorePrsParams()
312 {
313   if (!myPipeCopy)
314     myPipeCopy = VISU_Plot3DPL::New();
315   if (myPrs)
316     myPrs->GetPipeLine()->ShallowCopy(myPipeCopy, false);
317 }
318
319 //=======================================================================
320 //function : onPositionSpn
321 //purpose  : update absolute position range
322 //=======================================================================
323 void VisuGUI_Plot3DPane::onPositionSpn()
324 {
325   if (myPrs && !RelativeChkB->isChecked()) {
326     vtkFloatingPointType minPos, maxPos;
327     storePrsParams();
328     myPrs->GetSpecificPL()->GetMinMaxPosition(minPos, maxPos);
329     restorePrsParams();
330     if (minPos > PositionSpn->value())
331       minPos = PositionSpn->value();
332     if (maxPos < PositionSpn->value())
333       maxPos = PositionSpn->value();
334     PositionSpn->setRange(minPos, maxPos);
335   }
336   updatePreview();
337 }
338
339 //=======================================================================
340 //function : orientationChanged
341 //purpose  : update rotation labels and preview
342 //=======================================================================
343 void VisuGUI_Plot3DPane::orientationChanged(int Id)
344 {
345   if (Id == 0) { // RBxy->isChecked()
346     LabelRot1->setText(tr("ROTATION_X"));
347     LabelRot2->setText(tr("ROTATION_Y"));
348   } else if (Id == 1) { // RByz->isChecked()
349     LabelRot1->setText(tr("ROTATION_Y"));
350     LabelRot2->setText(tr("ROTATION_Z"));
351   } else {
352     LabelRot1->setText(tr("ROTATION_Z"));
353     LabelRot2->setText(tr("ROTATION_X"));
354   }
355   updatePreview();
356 }
357
358 //=======================================================================
359 //function : onRelativePos
360 //purpose  : update position value and range
361 //=======================================================================
362 void VisuGUI_Plot3DPane::onRelativePos(bool isRelativePos)
363 {
364   vtkFloatingPointType minPos = 0., maxPos = 1., pos = PositionSpn->value();
365   if (myPrs) {
366     storePrsParams();
367     myPrs->GetSpecificPL()->GetMinMaxPosition(minPos, maxPos);
368     restorePrsParams();
369     if (-1e-7 < (maxPos - minPos) && (maxPos - minPos) < 1e-7) {
370       pos = 0;
371     } else {
372       if (isRelativePos) // absolute -> relative
373         pos = (pos - minPos) / (maxPos - minPos);
374       else  // relative -> absolute
375         pos = minPos * (1. - pos) + maxPos * pos;
376     }
377   }
378   if (isRelativePos) {
379     minPos = 0.;
380     maxPos = 1.;
381   }
382   PositionSpn->setMinimum(minPos);
383   PositionSpn->setMaximum(maxPos);
384   PositionSpn->setSingleStep((maxPos - minPos) / 10.);
385   PositionSpn->setValue(pos);
386 }
387
388 //=======================================================================
389 //function : onPrsType
390 //purpose  :
391 //=======================================================================
392 void VisuGUI_Plot3DPane::onPrsType(int id)
393 {
394   NbContoursSpn->setEnabled(id == CONTOUR_PRS_ID);
395 }
396
397 //=======================================================================
398 //function : updatePreview
399 //purpose  :
400 //=======================================================================
401 void VisuGUI_Plot3DPane::updatePreview()
402 {
403   if(myPreviewActor){
404     vtkRenderer* aRend       = myPreviewActor->GetRenderer();
405     vtkRenderWindow* aWnd = aRend->GetRenderWindow();
406     if (!aWnd) return;
407   }
408  if (myInitFromPrs || !myPrs || !myViewWindow)
409     return;
410   bool fitall = false;
411   if (PreviewChkB->isChecked()) // place preview plane
412   {
413     // get plane preview actor
414     TPlane* planePreview = (TPlane*) myPreviewActor;
415     if (!planePreview) {
416       myPreviewActor = planePreview = new TPlane(myPrs->GetInput()->GetLength());
417       myViewWindow->AddActor(planePreview);
418       fitall = !VISU::FindActor(myViewWindow, myPrs);
419     }
420     // set plane parameters corresponding to control values
421     storePrsParams();
422     vtkFloatingPointType normal[3], origin[3];
423     myPrs->GetSpecificPL()->GetBasePlane(origin, normal, true);
424     planePreview->Set(origin, normal);
425     restorePrsParams();
426   }
427   if (myPreviewActor)
428     myPreviewActor->SetVisibility(PreviewChkB->isChecked());
429
430   renderViewFrame(myViewWindow);
431
432   if (fitall && VISU::GetResourceMgr()->booleanValue("VISU","automatic_fit_all",false)) {
433     myPreviewActor->SetInfinitive(false);
434     myViewWindow->onFitAll();
435     myPreviewActor->SetInfinitive(true);
436   }
437 }
438
439 //=======================================================================
440 //function : initFromPrsObject
441 //purpose  :
442 //=======================================================================
443 void VisuGUI_Plot3DPane::initFromPrsObject(VISU::Plot3D_i* thePrs)
444 {
445   myInitFromPrs = true;
446   myPrs = thePrs;
447
448   // orientation
449   int id;
450   switch (thePrs->GetOrientationType()) {
451   case VISU::Plot3D::XY: id = 0; break;
452   case VISU::Plot3D::YZ: id = 1; break;
453   default: id = 2;
454   }
455   GBOrientation->button(id)->click();
456
457   // rotation
458   Rot1->setValue(thePrs->GetRotateX() * 180./PI);
459   Rot2->setValue(thePrs->GetRotateY() * 180./PI);
460
461   // position
462   RelativeChkB->setChecked(thePrs->IsPositionRelative());
463   onRelativePos(thePrs->IsPositionRelative()); // update range
464   PositionSpn->setValue(thePrs->GetPlanePosition());
465
466   // scale
467   ScaleSpn->setValue(thePrs->GetScaleFactor());
468
469   // prs type
470   id = thePrs->GetIsContourPrs() ? CONTOUR_PRS_ID : SURFACE_PRS_ID;
471   GBPrsType->button(id)->click();
472
473   // nb contours
474   NbContoursSpn->setValue(thePrs->GetNbOfContours());
475
476   // disable cutting plane controls if the mesh is planar
477
478   if (thePrs->GetPipeLine()->IsPlanarInput())
479   {
480     //GBOrientation->setEnabled(false);
481     GBoxOrient->setEnabled(false);
482     Rot1         ->setEnabled(false);
483     Rot2         ->setEnabled(false);
484     PositionSpn  ->setEnabled(false);
485     RelativeChkB ->setEnabled(false);
486     PreviewChkB  ->setEnabled(false);
487   }
488
489   myInitFromPrs = false;
490   updatePreview();
491 }
492
493 //=======================================================================
494 //function : storeToPrsObject
495 //purpose  :
496 //=======================================================================
497 int VisuGUI_Plot3DPane::storeToPrsObject(VISU::Plot3D_i* thePrs)
498 {
499   if (myInitFromPrs)
500     return 0;
501   // orientation
502   int id = GBOrientation->id (GBOrientation->checkedButton());
503   VISU::Plot3D::Orientation ori;
504   switch (id) {
505   case 0 : ori = VISU::Plot3D::XY; break;
506   case 1 : ori = VISU::Plot3D::YZ; break;
507   default: ori = VISU::Plot3D::ZX;
508   }
509   // rotation
510   thePrs->SetOrientation(ori, Rot1->value()*PI/180., Rot2->value()*PI/180.);
511
512   // position
513   thePrs->SetPlanePosition(PositionSpn->value(), RelativeChkB->isChecked());
514
515   // scale
516   thePrs->SetScaleFactor(ScaleSpn->value());
517
518   // prs type
519   id = GBPrsType->id (GBPrsType->checkedButton());
520   thePrs->SetContourPrs(id == CONTOUR_PRS_ID);
521
522   // nb contours
523   thePrs->SetNbOfContours(NbContoursSpn->value());
524
525   return 1;
526 }
527
528 //=======================================================================
529 //function : check
530 //purpose  :
531 //=======================================================================
532 bool VisuGUI_Plot3DPane::check()
533 {
534   if(!myPreviewActor) return true;
535   
536   vtkRenderer* aRend    = myPreviewActor->GetRenderer();
537   vtkRenderWindow* aWnd = aRend->GetRenderWindow();
538   if(aRend && aWnd){
539     myPreviewActor->SetVisibility(false);
540     myViewWindow->RemoveActor(myPreviewActor);
541     myPreviewActor->Delete();
542     myPreviewActor = 0;
543   }
544     
545   return true;
546 }
547
548 void VisuGUI_Plot3DPane::setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos)
549 {
550   // Set plane
551   int id;
552   switch (theOrientation) {
553   case VISU::Plot3D::XY: id = 0; break;
554   case VISU::Plot3D::YZ: id = 1; break;
555   default: id = 2;
556   }
557   GBOrientation->button(id)->click();
558   GBoxOrient->setEnabled(false);
559
560
561   // Set rotation
562   Rot1->setValue(theXRotation * 180./PI);
563   Rot1->setEnabled(false);
564   Rot2->setValue(theYRotation * 180./PI);
565   Rot2->setEnabled(false);
566
567   // Set position
568   RelativeChkB->setChecked(false);
569   onRelativePos(false); // update range
570   PositionSpn->setValue(thePlanePos);
571   RelativeChkB->setEnabled(false);
572   PositionSpn->setEnabled(false);
573 }
574
575
576 //=======================================================================
577 //function : Constructor
578 //purpose  :
579 //=======================================================================
580 VisuGUI_Plot3DDlg::VisuGUI_Plot3DDlg (SalomeApp_Module* theModule)
581   : VisuGUI_ScalarBarBaseDlg(theModule)
582 {
583   setWindowTitle(tr("TITLE"));
584   setSizeGripEnabled(TRUE);
585
586   QVBoxLayout* TopLayout = new QVBoxLayout(this);
587   TopLayout->setSpacing(6);
588   TopLayout->setMargin(11);
589
590   myTabBox = new QTabWidget (this);
591   myIsoPane = new VisuGUI_Plot3DPane (this);
592   if ( myIsoPane->layout()  )
593     myIsoPane->layout()->setMargin(5);
594   myTabBox->addTab(myIsoPane, tr("PLOT3D_TAB_TITLE"));
595   myInputPane = new VisuGUI_InputPane(VISU::TPLOT3D, theModule, this);
596   myTabBox->addTab(GetScalarPane(), tr("SCALAR_BAR_TAB_TITLE"));
597   myTabBox->addTab(myInputPane, tr("INPUT_TAB_TITLE"));
598
599   TopLayout->addWidget(myTabBox);
600
601   QGroupBox* GroupButtons = new QGroupBox (this );
602   GroupButtons->setGeometry(QRect(10, 10, 281, 48));
603   //GroupButtons->setColumnLayout(0, Qt::Vertical);
604   //GroupButtons->layout()->setSpacing(0);
605   //GroupButtons->layout()->setMargin(0);
606   QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons);
607   GroupButtonsLayout->setAlignment(Qt::AlignTop);
608   GroupButtonsLayout->setSpacing(6);
609   GroupButtonsLayout->setMargin(11);
610
611   QPushButton* buttonOk = new QPushButton (tr("BUT_OK"), GroupButtons);
612   buttonOk->setAutoDefault(TRUE);
613   buttonOk->setDefault(TRUE);
614   GroupButtonsLayout->addWidget(buttonOk, 0, 0);
615   GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
616   QPushButton* buttonCancel = new QPushButton (tr("BUT_CANCEL") , GroupButtons);
617   buttonCancel->setAutoDefault(TRUE);
618   GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
619   QPushButton* buttonHelp = new QPushButton (tr("BUT_HELP") , GroupButtons);
620   buttonHelp->setAutoDefault(TRUE);
621   GroupButtonsLayout->addWidget(buttonHelp, 0, 3);
622
623   TopLayout->addWidget(GroupButtons);
624
625   // signals and slots connections
626   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
627   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
628   connect(buttonHelp,   SIGNAL(clicked()), this, SLOT(onHelp()));
629 }
630
631 VisuGUI_Plot3DDlg::~VisuGUI_Plot3DDlg()
632 {}
633
634 //=======================================================================
635 //function : accept
636 //purpose  :
637 //=======================================================================
638 void VisuGUI_Plot3DDlg::accept()
639 {
640   if (myIsoPane->check() && GetScalarPane()->check())
641     VisuGUI_ScalarBarBaseDlg::accept();
642 }
643
644 //=======================================================================
645 //function : reject
646 //purpose  :
647 //=======================================================================
648 void VisuGUI_Plot3DDlg::reject()
649 {
650   VisuGUI_ScalarBarBaseDlg::reject();
651 }
652
653 //=======================================================================
654 //function : initFromPrsObject
655 //purpose  :
656 //=======================================================================
657 void VisuGUI_Plot3DDlg::initFromPrsObject( VISU::ColoredPrs3d_i* thePrs, 
658                                            bool theInit )
659 {
660   if( theInit )
661     myPrsCopy = VISU::TSameAsFactory<VISU::TPLOT3D>().Create(thePrs, VISU::ColoredPrs3d_i::EDoNotPublish);
662
663   VisuGUI_ScalarBarBaseDlg::initFromPrsObject(myPrsCopy, theInit);
664
665   myIsoPane->initFromPrsObject(myPrsCopy);
666
667   if( !theInit )
668     return;
669
670   myInputPane->initFromPrsObject( myPrsCopy );
671   myTabBox->setCurrentIndex( 0 );
672 }
673
674 //=======================================================================
675 //function : storeToPrsObject
676 //purpose  :
677 //=======================================================================
678 int VisuGUI_Plot3DDlg::storeToPrsObject (VISU::ColoredPrs3d_i* thePrs)
679 {
680   if(!myInputPane->check() || !GetScalarPane()->check())
681     return 0;
682   
683   int anIsOk = myInputPane->storeToPrsObject( myPrsCopy );
684   anIsOk &= GetScalarPane()->storeToPrsObject( myPrsCopy );
685   anIsOk &= myIsoPane->storeToPrsObject( myPrsCopy );
686
687   VISU::TSameAsFactory<VISU::TPLOT3D>().Copy(myPrsCopy, thePrs);
688
689   return anIsOk;
690 }
691
692 //=======================================================================
693 //function : onHelp
694 //purpose  :
695 //=======================================================================
696 QString VisuGUI_Plot3DDlg::GetContextHelpFilePath()
697 {
698   return "plot_3d_page.html";
699 }
700
701 //=======================================================================
702 //function : setPlane
703 //purpose  :
704 //=======================================================================
705 void VisuGUI_Plot3DDlg::setPlane(int theOrientation, double theXRotation, double theYRotation, double thePlanePos)
706 {
707   myIsoPane->setPlane(theOrientation, theXRotation, theYRotation, thePlanePos);
708 }