Salome HOME
Portation on new based dialog
[modules/smesh.git] / src / SMESHGUI / SMESHGUI_NodesDlg.cxx
1 //  SMESH SMESHGUI : GUI for SMESH 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   : SMESHGUI_NodesDlg.cxx
25 //  Author : Nicolas REJNERI
26 //  Module : SMESH
27 //  $Header$
28
29 #include "SMESHGUI_NodesDlg.h"
30 #include <SMESHGUI.h>
31 #include <SMESHGUI_SpinBox.h>
32
33 #include <SUIT_ResourceMgr.h>
34
35 #include <qlayout.h>
36 #include <qbuttongroup.h>
37 #include <qlabel.h>
38 #include <qradiobutton.h>
39
40 //=================================================================================
41 // class    : SMESHGUI_NodesDlg()
42 // purpose  :
43 //=================================================================================
44 SMESHGUI_NodesDlg::SMESHGUI_NodesDlg()
45 : SMESHGUI_Dialog( 0, false, false, OK | Apply | Close )
46 {
47   QPixmap image0( resMgr()->loadPixmap("SMESH", tr("ICON_DLG_NODE")));
48   setName("SMESHGUI_NodesDlg");
49   resize(303, 185);
50   setCaption(tr("MESH_NODE_TITLE"));
51   setSizeGripEnabled(TRUE);
52   QGridLayout* SMESHGUI_NodesDlgLayout = new QGridLayout(mainFrame());
53   SMESHGUI_NodesDlgLayout->setSpacing(0);
54   SMESHGUI_NodesDlgLayout->setMargin(0);
55
56   /***************************************************************/
57   QButtonGroup* GroupConstructors = new QButtonGroup(mainFrame(), "GroupConstructors");
58   GroupConstructors->setTitle(tr("MESH_NODE" ));
59   GroupConstructors->setExclusive(TRUE);
60   GroupConstructors->setColumnLayout(0, Qt::Vertical);
61   GroupConstructors->layout()->setSpacing(0);
62   GroupConstructors->layout()->setMargin(0);
63   QGridLayout* GroupConstructorsLayout = new QGridLayout(GroupConstructors->layout());
64   GroupConstructorsLayout->setAlignment(Qt::AlignTop);
65   GroupConstructorsLayout->setSpacing(6);
66   GroupConstructorsLayout->setMargin(11);
67   QRadioButton* Constructor1 = new QRadioButton(GroupConstructors, "Constructor1");
68   Constructor1->setText(tr("" ));
69   Constructor1->setPixmap(image0);
70   Constructor1->setChecked(TRUE);
71   GroupConstructorsLayout->addWidget(Constructor1, 0, 0);
72   QSpacerItem* spacer_2 = new QSpacerItem(20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum);
73   GroupConstructorsLayout->addItem(spacer_2, 0, 1);
74   SMESHGUI_NodesDlgLayout->addWidget(GroupConstructors, 0, 0);
75
76   /***************************************************************/
77   QGroupBox* GroupCoordinates = new QGroupBox(mainFrame(), "GroupCoordinates");
78   GroupCoordinates->setTitle(tr("SMESH_COORDINATES" ));
79   GroupCoordinates->setColumnLayout(0, Qt::Vertical);
80   GroupCoordinates->layout()->setSpacing(0);
81   GroupCoordinates->layout()->setMargin(0);
82   QGridLayout* GroupCoordinatesLayout = new QGridLayout(GroupCoordinates->layout());
83   GroupCoordinatesLayout->setAlignment(Qt::AlignTop);
84   GroupCoordinatesLayout->setSpacing(6);
85   GroupCoordinatesLayout->setMargin(11);
86   QLabel* TextLabel_X = new QLabel(GroupCoordinates, "TextLabel_X");
87   TextLabel_X->setText(tr("SMESH_X" ));
88   GroupCoordinatesLayout->addWidget(TextLabel_X, 0, 0);
89   QLabel* TextLabel_Y = new QLabel(GroupCoordinates, "TextLabel_Y");
90   TextLabel_Y->setText(tr("SMESH_Y" ));
91   GroupCoordinatesLayout->addWidget(TextLabel_Y, 0, 2);
92
93   QLabel* TextLabel_Z = new QLabel(GroupCoordinates, "TextLabel_Z");
94   TextLabel_Z->setText(tr("SMESH_Z" ));
95   GroupCoordinatesLayout->addWidget(TextLabel_Z, 0, 4);
96
97   SpinBox_X = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_X");
98   GroupCoordinatesLayout->addWidget(SpinBox_X, 0, 1);
99
100   SpinBox_Y = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_Y");
101   GroupCoordinatesLayout->addWidget(SpinBox_Y, 0, 3);
102
103   SpinBox_Z = new SMESHGUI_SpinBox(GroupCoordinates, "SpinBox_Z");
104   GroupCoordinatesLayout->addWidget(SpinBox_Z, 0, 5);
105
106   SpinBox_X->RangeStepAndValidator(-999.999, +999.999, 25.0, 3);
107   SpinBox_Y->RangeStepAndValidator(-999.999, +999.999, 25.0, 3);
108   SpinBox_Z->RangeStepAndValidator(-999.999, +999.999, 25.0, 3);
109   
110   connect(SpinBox_X, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double)));
111   connect(SpinBox_Y, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double)));
112   connect(SpinBox_Z, SIGNAL(valueChanged(double)), this, SIGNAL(valueChanged(double)));
113   
114   SMESHGUI_NodesDlgLayout->addWidget(GroupCoordinates, 1, 0);
115
116   setFocusProxy( SpinBox_X );
117 }
118
119 //=======================================================================
120 // function : ~SMESHGUI_NodesDlg()
121 // purpose  : Destructor
122 //=======================================================================
123 SMESHGUI_NodesDlg::~SMESHGUI_NodesDlg()
124 {
125 }
126
127 //=======================================================================
128 // function : coords()
129 // purpose  : 
130 //=======================================================================
131 void SMESHGUI_NodesDlg::coords( double& x, double& y, double& z ) const
132 {
133   x = SpinBox_X->value();
134   y = SpinBox_Y->value();
135   z = SpinBox_Z->value();
136 }
137
138 //=======================================================================
139 // function : setCoords()
140 // purpose  :
141 //=======================================================================
142 void SMESHGUI_NodesDlg::setCoords( const double x, const double y, const double z )
143 {
144   SpinBox_X->setValue( x );
145   SpinBox_Y->setValue( y );
146   SpinBox_Z->setValue( z );
147 }