Salome HOME
NRI : merge from 1.2c
[modules/visu.git] / src / VISUGUI / VisuGUI_SelVectCompDlg.cxx
1 //  VISU VISUGUI : GUI of VISU component
2 //
3 //  Copyright (C) 2003  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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
21 //
22 //
23 //
24 //  File   : VisuGUI_SelVectCompDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND 
26 //  Module : VISU
27 //  $Header$
28
29 using namespace std;
30 #include "VisuGUI_SelVectCompDlg.h"
31 #include <qlayout.h>
32
33 /*!
34   Constructor
35 */
36 VisuGUI_SelVectCompDlg::VisuGUI_SelVectCompDlg( QWidget* parent,  const char* name, bool modal, WFlags fl )
37     : QDialog( parent, name, modal, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
38 {
39   if ( !name )
40     setName( "VisuGUI_SelVectCompDlg" );
41   setCaption( tr( "Vector Field" ) );
42   setSizeGripEnabled( true );
43
44   QVBoxLayout* TopLayout = new QVBoxLayout( this ); 
45   TopLayout->setSpacing( 6 );
46   TopLayout->setMargin( 11 );
47   
48   Comment1_2 = new QLabel( tr( "Select a component of the vector, or modulus," ), this, "Comment1_2" );
49   Comment1_2->setAlignment( AlignCenter );
50
51   Comment2_2 = new QLabel( tr( "to be displayed as a scalar result" ), this, "Comment2_2" );
52   Comment2_2->setAlignment( AlignCenter );
53
54   SelComp = new QButtonGroup( this, "SelComp" );
55   SelComp->setColumnLayout(0, Qt::Vertical );
56   SelComp->layout()->setSpacing( 0 );
57   SelComp->layout()->setMargin( 0 );
58   QGridLayout* SelCompLayout = new QGridLayout( SelComp->layout() );
59   SelCompLayout->setAlignment( Qt::AlignTop );
60   SelCompLayout->setSpacing( 6 );
61   SelCompLayout->setMargin( 11 );
62   
63   Comp1 = new QRadioButton( tr( "Component 1" ), SelComp, "Comp1" );
64   SelCompLayout->addWidget( Comp1, 0, 0 );
65
66   Modulus = new QRadioButton( tr( "Modulus" ), SelComp, "Modulus" );
67   Modulus->setChecked( TRUE );
68   SelCompLayout->addWidget( Modulus, 0, 1 );
69
70   Comp2 = new QRadioButton( tr( "Component 2" ), SelComp, "Comp2" );
71   SelCompLayout->addWidget( Comp2, 1, 0 );
72
73   Comp3 = new QRadioButton( tr( "Component 3" ), SelComp, "Comp3" );
74   SelCompLayout->addWidget( Comp3, 2, 0 );
75
76   GroupButtons = new QGroupBox( this, "GroupButtons" );
77   GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
78   GroupButtons->setTitle( tr( ""  ) );
79   GroupButtons->setColumnLayout(0, Qt::Vertical );
80   GroupButtons->layout()->setSpacing( 0 );
81   GroupButtons->layout()->setMargin( 0 );
82   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
83   GroupButtonsLayout->setAlignment( Qt::AlignTop );
84   GroupButtonsLayout->setSpacing( 6 );
85   GroupButtonsLayout->setMargin( 11 );
86
87   buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
88   buttonOk->setAutoDefault( TRUE );
89   buttonOk->setDefault( TRUE );
90   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
91   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
92   buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
93   buttonCancel->setAutoDefault( TRUE );
94   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
95   
96   TopLayout->addWidget( Comment1_2,   0, 0 );
97   TopLayout->addWidget( Comment2_2,   1, 0 );
98   TopLayout->addWidget( SelComp,      2, 0 );
99   TopLayout->addWidget( GroupButtons, 3, 0 );
100
101   // signals and slots connections
102   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
103   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
104 }
105
106 /*!
107   Destructor
108 */
109 VisuGUI_SelVectCompDlg::~VisuGUI_SelVectCompDlg()
110 {
111 }
112
113 /*!
114   Gets selection
115 */
116 int VisuGUI_SelVectCompDlg::whatIsChecked()
117 {
118   int ret = 0;
119   if ( Modulus->isChecked() )
120     ret = 0;
121   else if ( Comp1->isChecked() )
122     ret = 1;
123   else if ( Comp2->isChecked() )
124     ret = 2;
125   else if ( Comp3->isChecked() )
126     ret = 3;
127   return ret;
128 }
129