Salome HOME
PAL9391 - remarks
[modules/visu.git] / src / VISUGUI / VisuGUI_DeformedShapeDlg.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_MagnitudeDlg.cxx
25 //  Author : Laurent CORNABE & Hubert ROLLAND
26 //  Module : VISU
27 //  $Header$
28
29 #include "VisuGUI_DeformedShapeDlg.h"
30
31 #include "VisuGUI_Tools.h"
32
33 #include "VISU_DeformedShape_i.hh"
34
35 #include "SalomeApp_Module.h"
36 #include "SUIT_Desktop.h"
37
38 #include <qlayout.h>
39 #include <qtabwidget.h>
40
41 using namespace std;
42
43 /*!
44  * Constructor
45  */
46 VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg (SalomeApp_Module* theModule)
47     : QDialog(VISU::GetDesktop(theModule), "VisuGUI_DeformedShapeDlg", true,
48               WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
49 {
50   setCaption(tr("DLG_TITLE"));
51   setSizeGripEnabled(TRUE);
52
53   QVBoxLayout* TopLayout = new QVBoxLayout (this);
54   TopLayout->setSpacing(6);
55   TopLayout->setMargin(11);
56
57   QTabWidget* aTabBox = new QTabWidget (this);
58
59   // Deformed shape pane
60   QVBox* aBox = new QVBox (this);
61   aBox->setMargin(11);
62   QFrame* TopGroup = new QFrame (aBox, "TopGroup");
63   TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken);
64   TopGroup->setLineWidth(1);
65   QGridLayout* TopGroupLayout = new QGridLayout (TopGroup);
66   TopGroupLayout->setAlignment(Qt::AlignTop | Qt::AlignCenter);
67   TopGroupLayout->setSpacing(6);
68   TopGroupLayout->setMargin(11);
69
70   //   Scale factor
71   QLabel* ScaleLabel = new QLabel (tr("SCALE_FACTOR"), TopGroup, "ScaleLabel");
72   TopGroupLayout->addWidget(ScaleLabel, 0, 0);
73
74   ScalFact = new QtxDblSpinBox (0.0, 1.0E+38, 0.1, TopGroup);
75   ScalFact->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
76   ScalFact->setPrecision(5);
77   ScalFact->setValue(0.1);
78   TopGroupLayout->addWidget(ScalFact, 0, 1);
79
80   //   Magnitude coloring
81   UseMagn = new QCheckBox (tr("MAGNITUDE_COLORING"), TopGroup, "UseMagn");
82   UseMagn->setChecked(true);
83   TopGroupLayout->addMultiCellWidget(UseMagn, 1, 1, 0, 1);
84
85   aTabBox->addTab(aBox, tr("DEFORMED_SHAPE_TAB"));
86
87   // Scalar bar pane
88   myScalarPane = new VisuGUI_ScalarBarPane (this, false);
89   myScalarPane->setMargin(5);
90
91   aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
92
93   // Buttons
94   QGroupBox* GroupButtons = new QGroupBox (this, "GroupButtons");
95   GroupButtons->setGeometry(QRect(10, 10, 281, 48));
96   GroupButtons->setColumnLayout(0, Qt::Vertical);
97   GroupButtons->layout()->setSpacing(0);
98   GroupButtons->layout()->setMargin(0);
99   QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons->layout());
100   GroupButtonsLayout->setAlignment(Qt::AlignTop);
101   GroupButtonsLayout->setSpacing(6);
102   GroupButtonsLayout->setMargin(11);
103
104   QPushButton* buttonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk");
105   buttonOk->setAutoDefault(TRUE);
106   buttonOk->setDefault(TRUE);
107   GroupButtonsLayout->addWidget(buttonOk, 0, 0);
108
109   GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding,
110                                                QSizePolicy::Minimum), 0, 1);
111
112   QPushButton* buttonCancel = new QPushButton (tr("&Cancel") , GroupButtons, "buttonCancel");
113   buttonCancel->setAutoDefault(TRUE);
114   GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
115
116   // Add Tab box and Buttons to the top layout
117   TopLayout->addWidget(aTabBox);
118   TopLayout->addWidget(GroupButtons);
119
120   // signals and slots connections
121   connect(buttonOk,     SIGNAL(clicked()), this, SLOT(accept()));
122   connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
123 }
124
125 void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::DeformedShape_i* thePrs)
126 {
127   myScalarPane->initFromPrsObject(thePrs);
128   setFactor(thePrs->GetScale());
129   UseMagn->setChecked(thePrs->IsColored());
130 }
131
132 int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) {
133   myScalarPane->storeToPrsObject(thePrs);
134   thePrs->SetScale(getFactor());
135   thePrs->ShowColored(isColored());
136   return 1;
137 }
138
139 void VisuGUI_DeformedShapeDlg::accept() {
140   if (myScalarPane->check())  QDialog::accept();
141 }