Salome HOME
This commit was generated by cvs2git to track changes on a CVS vendor
[modules/visu.git] / src / VISUGUI / VisuGUI_SelVectCompDlg.cxx
1 using namespace std;
2 //  File      : VisuGUI_SelVectCompDlg.cxx
3 //  Created   : Wed Aug 01 10:23:06 2001
4 //  Author    : Laurent CORNABE & Hubert ROLLAND 
5 //  Project   : SALOME
6 //  Module    : VISUGUI
7 //  Copyright : PRINCIPIA
8 //  $Header$
9
10 #include "VisuGUI_SelVectCompDlg.h"
11 #include <qlayout.h>
12
13 /*!
14   Constructor
15 */
16 VisuGUI_SelVectCompDlg::VisuGUI_SelVectCompDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
17     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
18 {
19   if ( !name )
20     setName( "VisuGUI_SelVectCompDlg" );
21   setCaption( tr( "Vector Field" ) );
22   setSizeGripEnabled( true );
23
24   QVBoxLayout* TopLayout = new QVBoxLayout( this ); 
25   TopLayout->setSpacing( 6 );
26   TopLayout->setMargin( 11 );
27   
28   Comment1_2 = new QLabel( tr( "Select a component of the vector, or modulus," ), this, "Comment1_2" );
29   Comment1_2->setAlignment( AlignCenter );
30
31   Comment2_2 = new QLabel( tr( "to be displayed as a scalar result" ), this, "Comment2_2" );
32   Comment2_2->setAlignment( AlignCenter );
33
34   SelComp = new QButtonGroup( this, "SelComp" );
35   SelComp->setColumnLayout(0, Qt::Vertical );
36   SelComp->layout()->setSpacing( 0 );
37   SelComp->layout()->setMargin( 0 );
38   QGridLayout* SelCompLayout = new QGridLayout( SelComp->layout() );
39   SelCompLayout->setAlignment( Qt::AlignTop );
40   SelCompLayout->setSpacing( 6 );
41   SelCompLayout->setMargin( 11 );
42   
43   Comp1 = new QRadioButton( tr( "Component 1" ), SelComp, "Comp1" );
44   SelCompLayout->addWidget( Comp1, 0, 0 );
45
46   Modulus = new QRadioButton( tr( "Modulus" ), SelComp, "Modulus" );
47   Modulus->setChecked( TRUE );
48   SelCompLayout->addWidget( Modulus, 0, 1 );
49
50   Comp2 = new QRadioButton( tr( "Component 2" ), SelComp, "Comp2" );
51   SelCompLayout->addWidget( Comp2, 1, 0 );
52
53   Comp3 = new QRadioButton( tr( "Component 3" ), SelComp, "Comp3" );
54   SelCompLayout->addWidget( Comp3, 2, 0 );
55
56   GroupButtons = new QGroupBox( this, "GroupButtons" );
57   GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
58   GroupButtons->setTitle( tr( ""  ) );
59   GroupButtons->setColumnLayout(0, Qt::Vertical );
60   GroupButtons->layout()->setSpacing( 0 );
61   GroupButtons->layout()->setMargin( 0 );
62   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
63   GroupButtonsLayout->setAlignment( Qt::AlignTop );
64   GroupButtonsLayout->setSpacing( 6 );
65   GroupButtonsLayout->setMargin( 11 );
66
67   buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
68   buttonOk->setAutoDefault( TRUE );
69   buttonOk->setDefault( TRUE );
70   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
71   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
72   buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
73   buttonCancel->setAutoDefault( TRUE );
74   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
75   
76   TopLayout->addWidget( Comment1_2,   0, 0 );
77   TopLayout->addWidget( Comment2_2,   1, 0 );
78   TopLayout->addWidget( SelComp,      2, 0 );
79   TopLayout->addWidget( GroupButtons, 3, 0 );
80
81   // signals and slots connections
82   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
83   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
84 }
85
86 /*!
87   Destructor
88 */
89 VisuGUI_SelVectCompDlg::~VisuGUI_SelVectCompDlg()
90 {
91 }
92
93 /*!
94   Gets selection
95 */
96 int VisuGUI_SelVectCompDlg::whatIsChecked()
97 {
98   int ret = 0;
99   if ( Modulus->isChecked() )
100     ret = 0;
101   else if ( Comp1->isChecked() )
102     ret = 1;
103   else if ( Comp2->isChecked() )
104     ret = 2;
105   else if ( Comp3->isChecked() )
106     ret = 3;
107   return ret;
108 }
109