Salome HOME
IPAL9283,9286,9295,9296,9297; some icons restored
[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 #include "VISU_DeformedShape_i.hh"
31
32 #include <qlayout.h>
33 #include <qtabwidget.h>
34
35 using namespace std;
36
37 /*!
38   Constructor
39 */
40 VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg(QWidget* parent)
41     : QDialog( parent, "VisuGUI_DeformedShapeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
42 {
43   setCaption(tr("DLG_TITLE"));
44   setSizeGripEnabled( TRUE );
45
46   QVBoxLayout* TopLayout = new QVBoxLayout( this ); 
47   TopLayout->setSpacing( 6 );
48   TopLayout->setMargin( 11 );
49   
50   QTabWidget* aTabBox = new QTabWidget(this);
51   
52   QVBox* aBox = new QVBox(this);
53   aBox->setMargin( 11 );
54   QFrame* TopGroup = new QFrame( aBox, "TopGroup" );
55   TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken);
56   TopGroup->setLineWidth(1);
57   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup );
58   TopGroupLayout->setAlignment( Qt::AlignTop | Qt::AlignCenter );
59   TopGroupLayout->setSpacing( 6 );
60   TopGroupLayout->setMargin( 11 );
61
62   QLabel* ScaleLabel = new QLabel (tr("SCALE_FACTOR"), TopGroup, "ScaleLabel");
63   TopGroupLayout->addWidget( ScaleLabel, 0, 0 );
64
65   ScalFact = new QtxDblSpinBox( 0.0, 1.0E+38, 0.1, TopGroup);
66   ScalFact->setPrecision(5);
67   ScalFact->setValue( 0.1 );
68   TopGroupLayout->addWidget( ScalFact, 0, 1 );
69
70   UseMagn = new QCheckBox (tr("MAGNITUDE_COLORING"), TopGroup, "UseMagn");
71   UseMagn->setChecked(true);
72   TopGroupLayout->addMultiCellWidget(UseMagn, 1, 1, 0, 1);
73   //if (!enableUM)
74   //  UseMagn->hide();
75   aTabBox->addTab(aBox, tr("DEFORMED_SHAPE_TAB"));
76   
77   myScalarPane = new VisuGUI_ScalarBarPane(this, false);
78   myScalarPane->setMargin( 5 );
79   aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
80
81
82   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
83   GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
84   GroupButtons->setColumnLayout(0, Qt::Vertical );
85   GroupButtons->layout()->setSpacing( 0 );
86   GroupButtons->layout()->setMargin( 0 );
87   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
88   GroupButtonsLayout->setAlignment( Qt::AlignTop );
89   GroupButtonsLayout->setSpacing( 6 );
90   GroupButtonsLayout->setMargin( 11 );
91
92   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
93   buttonOk->setAutoDefault( TRUE );
94   buttonOk->setDefault( TRUE );
95   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
96   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
97   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
98   buttonCancel->setAutoDefault( TRUE );
99   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
100   
101   TopLayout->addWidget( aTabBox );
102   TopLayout->addWidget( GroupButtons );
103
104   // signals and slots connections
105   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
106   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
107 }
108
109
110 void VisuGUI_DeformedShapeDlg::initFromPrsObject(VISU::DeformedShape_i* thePrs) {
111   myScalarPane->initFromPrsObject(thePrs);
112   setFactor(thePrs->GetScale());
113   UseMagn->setChecked(thePrs->IsColored());
114 }
115
116
117 int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) {
118   myScalarPane->storeToPrsObject(thePrs);
119   thePrs->SetScale(getFactor());
120   thePrs->ShowColored(isColored());
121   return 1;
122 }
123
124
125 void VisuGUI_DeformedShapeDlg::accept() {
126   if (myScalarPane->check())  QDialog::accept();
127 }
128