1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 CEA/DEN, EDF R&D
7 // File : VisuGUI_CutLinesDlg.cxx
11 #include "VisuGUI_CutLinesDlg.h"
14 #include <qtabwidget.h>
16 #include "QAD_Application.h"
17 #include "QAD_Desktop.h"
20 VisuGUI_CutLinesDlg::VisuGUI_CutLinesDlg()
21 : QDialog( QAD_Application::getDesktop(), "VisuGUI_CutLinesDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
23 setCaption( "Cut Lines Definition" );
24 setSizeGripEnabled( true );
26 QVBoxLayout* aMainLayout = new QVBoxLayout(this, 7, 6);
27 aMainLayout->setSpacing(5);
30 QTabWidget* aTabPane = new QTabWidget(this);
33 QFrame* aPlanePane = new QFrame(this);
34 QVBoxLayout* aPlaneLayout = new QVBoxLayout( aPlanePane, 5, 6 );
35 aPlaneLayout->addStretch();
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)));
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);
47 aPlaneLayout->addWidget( mySelPlane );
48 aPlaneLayout->addStretch();
50 QGroupBox* aRotBox = new QGroupBox( tr( "LBL_ROTATION" ), aPlanePane );
51 aRotBox->setColumnLayout(2, Qt::Horizontal );
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 );
60 aPlaneLayout->addWidget( aRotBox );
61 aPlaneLayout->addStretch();
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 );
71 aTabPane->addTab( aPlanePane, tr("LBL_LINES_PLANE") );
75 QFrame* aLinesPane = new QFrame(this);
76 QVBoxLayout* aLinesLayout = new QVBoxLayout( aLinesPane, 5, 6 );
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)));
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 );
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 );
97 QGroupBox* aRotBox2 = new QGroupBox( tr( "LBL_ROTATION" ), aLinesPane );
98 aRotBox2->setColumnLayout(2, Qt::Horizontal );
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 );
107 aLinesLayout->addWidget( aRotBox2 );
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 );
116 aTabPane->addTab( aLinesPane, tr("LBL_LINES_CUT") );
118 aMainLayout->addWidget(aTabPane);
121 QHBox* aBtnBox = new QHBox(this);
122 QHBoxLayout* aBtnLayout = (QHBoxLayout*) aBtnBox->layout();
123 aBtnLayout->setAutoAdd( false );
124 aBtnLayout->setSpacing( 5 );
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()));
132 aBtnLayout->addStretch();
134 QPushButton* aCloseBtn = new QPushButton(tr("BUT_CLOSE"), aBtnBox);
135 aBtnLayout->addWidget(aCloseBtn);
136 connect(aCloseBtn, SIGNAL(clicked()), this, SLOT(reject()));
138 aMainLayout->addWidget(aBtnBox);
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);
148 case VISU::CutPlanes::YZ:
149 ((QRadioButton*)mySelPlane->find(1))->setChecked(true);
152 case VISU::CutPlanes::ZX:
153 ((QRadioButton*)mySelPlane->find(2))->setChecked(true);
156 myRotXSpn->setValue(thePrs->GetRotateX()*180./PI);
157 myRotYSpn->setValue(thePrs->GetRotateY()*180./PI);
158 myPosSpn->setValue(thePrs->GetDisplacement());
160 myNbSpn->setValue( thePrs->GetNbLines() );
161 switch (thePrs->GetOrientationType2()) {
162 case VISU::CutPlanes::XY:
163 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
165 case VISU::CutPlanes::YZ:
166 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
168 case VISU::CutPlanes::ZX:
169 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
171 myRotXSpn2->setValue(thePrs->GetRotateX2()*180./PI);
172 myRotYSpn2->setValue(thePrs->GetRotateY2()*180./PI);
173 myPosSpn2->setValue(thePrs->GetDisplacement2());
177 //------------------------------------------------------------------------------
178 void VisuGUI_CutLinesDlg::storeToPrsObject(VISU::CutLines_i* thePrs) {
179 switch (mySelPlane->id(mySelPlane->selected())) {
181 thePrs->SetOrientationType(VISU::CutPlanes::XY);
184 thePrs->SetOrientationType(VISU::CutPlanes::YZ);
187 thePrs->SetOrientationType(VISU::CutPlanes::ZX);
189 thePrs->SetRotateX(myRotXSpn->value()*PI/180.);
190 thePrs->SetRotateY(myRotYSpn->value()*PI/180.);
191 thePrs->SetDisplacement(myPosSpn->value());
193 thePrs->SetNbLines((int)myNbSpn->value());
194 switch (mySelPlane2->id(mySelPlane2->selected())) {
196 thePrs->SetOrientationType2(VISU::CutPlanes::XY);
199 thePrs->SetOrientationType2(VISU::CutPlanes::YZ);
202 thePrs->SetOrientationType2(VISU::CutPlanes::ZX);
204 thePrs->SetRotateX2(myRotXSpn2->value()*PI/180.);
205 thePrs->SetRotateY2(myRotYSpn2->value()*PI/180.);
206 thePrs->SetDisplacement2(myPosSpn2->value());
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);
218 myRotXLbl->setText( tr("LBL_ROT_X"));
219 myRotYLbl->setText( tr("LBL_ROT_Y"));
220 ((QRadioButton*)mySelPlane2->find(1))->setChecked(true);
224 myRotXLbl->setText( tr("LBL_ROT_Y"));
225 myRotYLbl->setText( tr("LBL_ROT_Z"));
226 ((QRadioButton*)mySelPlane2->find(2))->setChecked(true);
230 myRotXLbl->setText( tr("LBL_ROT_Z"));
231 myRotYLbl->setText( tr("LBL_ROT_X"));
232 ((QRadioButton*)mySelPlane2->find(0))->setChecked(true);
238 //------------------------------------------------------------------------------
239 void VisuGUI_CutLinesDlg::onCutSelect(int theId) {
242 myRotXLbl2->setText( tr("LBL_ROT_X"));
243 myRotYLbl2->setText( tr("LBL_ROT_Y"));
246 myRotXLbl2->setText( tr("LBL_ROT_Y"));
247 myRotYLbl2->setText( tr("LBL_ROT_Z"));
250 myRotXLbl2->setText( tr("LBL_ROT_Z"));
251 myRotYLbl2->setText( tr("LBL_ROT_X"));