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