]> SALOME platform Git repositories - modules/visu.git/blob - src/VISUGUI/VisuGUI_CutLinesDlg.cxx
Salome HOME
NRI : Merge from V1_2.
[modules/visu.git] / src / VISUGUI / VisuGUI_CutLinesDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  CEA/DEN, EDF R&D
4 //
5 //
6 //
7 //  File   : VisuGUI_CutLinesDlg.cxx
8 //  Author : VSV
9 //  Module : VISU
10
11 #include "VisuGUI_CutLinesDlg.h"
12 #include <qlayout.h>
13 #include <qhbox.h>
14 #include <qtabwidget.h>
15
16 #include "QAD_Application.h"
17 #include "QAD_Desktop.h"
18
19
20 VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg()
21     : QDialog(  QAD_Application::getDesktop(), "VisuGUI_CutLinesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
22 {
23   setCaption( "Cut Lines Definition" );
24   setSizeGripEnabled( true );
25
26   QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
27   aMainLayout->setSpacing(5);
28   
29   // Tab pane
30   QTabWidget* aTabPane = new QTabWidget(this);
31
32   // Plane of lines
33   QFrame* aPlanePane = new QFrame(this);
34   QVBoxLayout* aPlaneLayout = new QVBoxLayout( aPlanePane, 5, 6 ); 
35   aPlaneLayout->addStretch();
36
37   mySelPlane = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aPlanePane);
38   mySelPlane->setInsideSpacing( 5 );
39   mySelPlane->setInsideMargin( 5 );
40   connect(mySelPlane, SIGNAL(clicked(int)), this, SLOT(onPlaneSelect(int)));
41
42   QRadioButton* aBxy = new QRadioButton( tr( "|| X-Y" ), mySelPlane);  // 0
43   QRadioButton* aByz = new QRadioButton( tr( "|| Y-Z" ), mySelPlane);  // 1
44   QRadioButton* aBzx = new QRadioButton( tr( "|| Z-X" ), mySelPlane);  // 2
45   aBzx->setChecked(true);
46
47   aPlaneLayout->addWidget( mySelPlane );
48   aPlaneLayout->addStretch();
49
50   QGroupBox* aRotBox = new QGroupBox( tr( "LBL_ROTATION" ), aPlanePane );
51   aRotBox->setColumnLayout(2, Qt::Horizontal );
52
53   myRotXLbl = new QLabel( tr( "LBL_ROT_X" ), aRotBox);
54   myRotXSpn = new QAD_SpinBoxDbl( aRotBox, -45, 45, 5 );
55   myRotXSpn->setValue( 0 );
56   myRotYLbl = new QLabel( tr( "LBL_ROT_Y" ), aRotBox );
57   myRotYSpn = new QAD_SpinBoxDbl( aRotBox, -45, 45, 5 );
58   myRotYSpn->setValue( 0 );
59
60   aPlaneLayout->addWidget( aRotBox );
61   aPlaneLayout->addStretch();
62   
63   QHBox* aPosBox = new QHBox(aPlanePane);
64   aPosBox->setSpacing(5);
65   QLabel* aPosLbl = new QLabel( tr( "LBL_POS" ), aPosBox );
66   myPosSpn = new QAD_SpinBoxDbl( aPosBox, 0, 1, 0.1 );
67   myPosSpn->setValue( 0.5 );  
68   aPlaneLayout->addWidget( aPosBox );
69  
70
71   aTabPane->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
72
73
74   // Number of lines
75   QFrame* aLinesPane = new QFrame(this);
76   QVBoxLayout* aLinesLayout = new QVBoxLayout( aLinesPane, 5, 6 ); 
77
78   mySelPlane2 = new QHButtonGroup( tr( "TXT_ORIENTATION" ), aLinesPane);
79   mySelPlane2->setInsideSpacing( 5 );
80   mySelPlane2->setInsideMargin( 5 );
81   connect(mySelPlane2, SIGNAL(clicked(int)), this, SLOT(onCutSelect(int)));
82
83   QRadioButton* aBxy2 = new QRadioButton( tr( "|| X-Y" ), mySelPlane2);  // 0
84   QRadioButton* aByz2 = new QRadioButton( tr( "|| Y-Z" ), mySelPlane2);  // 1
85   QRadioButton* aBzx2 = new QRadioButton( tr( "|| Z-X" ), mySelPlane2);  // 2
86   aBzx2->setEnabled(false);
87   aByz2->setChecked(true);
88   aLinesLayout->addWidget( mySelPlane2 );
89
90   QHBox* aNbBox = new QHBox(aLinesPane);
91   aNbBox->setSpacing(5);
92   QLabel* aNbLbl = new QLabel( tr( "LBL_NB_PLANS" ), aNbBox );
93   myNbSpn = new QAD_SpinBoxDbl( aNbBox, 1, 100, 1 );
94   myNbSpn->setValue( 10 );  
95   aLinesLayout->addWidget( aNbBox );
96
97   QGroupBox* aRotBox2 = new QGroupBox( tr( "LBL_ROTATION" ), aLinesPane );
98   aRotBox2->setColumnLayout(2, Qt::Horizontal );
99
100   myRotXLbl2 = new QLabel( tr( "LBL_ROT_X" ), aRotBox2);
101   myRotXSpn2 = new QAD_SpinBoxDbl( aRotBox2, -45, 45, 5 );
102   myRotXSpn2->setValue( 0 );
103   myRotYLbl2 = new QLabel( tr( "LBL_ROT_Y" ), aRotBox2 );
104   myRotYSpn2 = new QAD_SpinBoxDbl( aRotBox2, -45, 45, 5 );
105   myRotYSpn2->setValue( 0 );
106
107   aLinesLayout->addWidget( aRotBox2 );
108
109   QHBox* aPosBox2 = new QHBox(aLinesPane);
110   aPosBox2->setSpacing(5);
111   QLabel* aPosLbl2 = new QLabel( tr( "LBL_POS" ), aPosBox2 );
112   myPosSpn2 = new QAD_SpinBoxDbl( aPosBox2, 0, 1, 0.1 );
113   myPosSpn2->setValue( 0.5 );  
114   aLinesLayout->addWidget( aPosBox2 );
115  
116   aTabPane->addTab( aLinesPane, tr("LBL_LINES_CUT") );
117
118   aMainLayout->addWidget(aTabPane);
119
120   // Dialog buttons
121   QHBox* aBtnBox = new QHBox(this);
122   QHBoxLayout* aBtnLayout = (QHBoxLayout*) aBtnBox->layout(); 
123   aBtnLayout->setAutoAdd( false );
124   aBtnLayout->setSpacing( 5 );
125
126   QPushButton* aOkBtn = new QPushButton(tr( "VISU_BUT_OK" ),  aBtnBox);
127   aOkBtn->setAutoDefault( TRUE );
128   aOkBtn->setDefault( true );
129   aBtnLayout->addWidget(aOkBtn);
130   connect(aOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
131
132   aBtnLayout->addStretch();
133   
134   QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
135   aBtnLayout->addWidget(aCloseBtn);
136   connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
137   
138   aMainLayout->addWidget(aBtnBox);
139 }
140
141 //------------------------------------------------------------------------------
142 void VisuGUI_CutLinesDlg::initFromPrsObject(VISU::CutLines_i* thePrs) {
143   switch (thePrs->GetOrientationType()) {
144   case VISU::CutPlanes::XY:
145     ((QRadioButton*)mySelPlane->find(0))->setChecked(true);
146     onPlaneSelect(0);
147     break;
148   case VISU::CutPlanes::YZ:
149     ((QRadioButton*)mySelPlane->find(1))->setChecked(true);
150     onPlaneSelect(1);
151     break;
152   case VISU::CutPlanes::ZX:      
153     ((QRadioButton*)mySelPlane->find(2))->setChecked(true);
154     onPlaneSelect(2);
155   }
156   myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
157   myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
158   myPosSpn->setValue(thePrs->GetDisplacement());
159
160   myNbSpn->setValue( thePrs->GetNbLines() );  
161   switch (thePrs->GetOrientationType2()) {
162   case VISU::CutPlanes::XY:
163     ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
164     break;
165   case VISU::CutPlanes::YZ:
166     ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
167     break;
168   case VISU::CutPlanes::ZX:      
169     ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
170   }
171   myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI);
172   myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI);
173   myPosSpn2->setValue(thePrs->GetDisplacement2());
174 }
175
176
177 //------------------------------------------------------------------------------
178 void VisuGUI_CutLinesDlg::storeToPrsObject(VISU::CutLines_i* thePrs) {
179   switch (mySelPlane->id(mySelPlane->selected())) {
180   case 0:
181     thePrs->SetOrientationType(VISU::CutPlanes::XY);
182     break;
183   case 1:
184     thePrs->SetOrientationType(VISU::CutPlanes::YZ);
185     break;
186   case 2:
187     thePrs->SetOrientationType(VISU::CutPlanes::ZX);    
188   }
189   thePrs->SetRotateX(myRotXSpn->value()*PI/180.);
190   thePrs->SetRotateY(myRotYSpn->value()*PI/180.);
191   thePrs->SetDisplacement(myPosSpn->value());
192
193   thePrs->SetNbLines((int)myNbSpn->value());
194   switch (mySelPlane2->id(mySelPlane2->selected())) {
195   case 0:
196     thePrs->SetOrientationType2(VISU::CutPlanes::XY);
197     break;
198   case 1:
199     thePrs->SetOrientationType2(VISU::CutPlanes::YZ);
200     break;
201   case 2:
202     thePrs->SetOrientationType2(VISU::CutPlanes::ZX);    
203   }
204   thePrs->SetRotateX2(myRotXSpn2->value()*PI/180.);
205   thePrs->SetRotateY2(myRotYSpn2->value()*PI/180.);
206   thePrs->SetDisplacement2(myPosSpn2->value());
207 }
208
209
210 //------------------------------------------------------------------------------
211 void VisuGUI_CutLinesDlg::onPlaneSelect(int theId) {
212   for (int i = 0; i < mySelPlane2->count(); i++)
213     mySelPlane2->find(i)->setEnabled(true);
214   QButton* aBtn = mySelPlane2->find(theId);
215   aBtn->setEnabled(false);
216   switch (theId) {
217   case 0:
218     myRotXLbl->setText( tr("LBL_ROT_X"));
219     myRotYLbl->setText( tr("LBL_ROT_Y"));
220     ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);    
221     onCutSelect(1);
222     break;
223   case 1:
224     myRotXLbl->setText( tr("LBL_ROT_Y"));
225     myRotYLbl->setText( tr("LBL_ROT_Z"));
226     ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);    
227     onCutSelect(2);
228     break;
229   case 2:
230     myRotXLbl->setText( tr("LBL_ROT_Z"));
231     myRotYLbl->setText( tr("LBL_ROT_X"));
232     ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
233     onCutSelect(0);
234   }
235 }
236
237
238 //------------------------------------------------------------------------------
239 void VisuGUI_CutLinesDlg::onCutSelect(int theId) {
240   switch (theId) {
241   case 0:
242     myRotXLbl2->setText( tr("LBL_ROT_X"));
243     myRotYLbl2->setText( tr("LBL_ROT_Y"));
244     break;
245   case 1:
246     myRotXLbl2->setText( tr("LBL_ROT_Y"));
247     myRotYLbl2->setText( tr("LBL_ROT_Z"));
248     break;
249   case 2:
250     myRotXLbl2->setText( tr("LBL_ROT_Z"));
251     myRotYLbl2->setText( tr("LBL_ROT_X"));
252   }
253 }