1 // VISU VISUGUI : GUI of VISU component
3 // Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
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.
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.
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
20 // See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
24 // File : VisuGUI_MagnitudeDlg.cxx
25 // Author : Laurent CORNABE & Hubert ROLLAND
29 #include "VisuGUI_DeformedShapeDlg.h"
30 #include "VISU_DeformedShape_i.hh"
33 #include <qtabwidget.h>
40 VisuGUI_DeformedShapeDlg::VisuGUI_DeformedShapeDlg(QWidget* parent)
41 : QDialog( parent, "VisuGUI_DeformedShapeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
43 setCaption(tr("DLG_TITLE"));
44 setSizeGripEnabled( TRUE );
46 QVBoxLayout* TopLayout = new QVBoxLayout( this );
47 TopLayout->setSpacing( 6 );
48 TopLayout->setMargin( 11 );
50 QTabWidget* aTabBox = new QTabWidget(this);
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 );
62 QLabel* ScaleLabel = new QLabel (tr("SCALE_FACTOR"), TopGroup, "ScaleLabel");
63 TopGroupLayout->addWidget( ScaleLabel, 0, 0 );
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 );
70 UseMagn = new QCheckBox (tr("MAGNITUDE_COLORING"), TopGroup, "UseMagn");
71 UseMagn->setChecked(true);
72 TopGroupLayout->addMultiCellWidget(UseMagn, 1, 1, 0, 1);
75 aTabBox->addTab(aBox, tr("DEFORMED_SHAPE_TAB"));
77 myScalarPane = new VisuGUI_ScalarBarPane(this, false);
78 myScalarPane->setMargin( 5 );
79 aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
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 );
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 );
101 TopLayout->addWidget( aTabBox );
102 TopLayout->addWidget( GroupButtons );
104 // signals and slots connections
105 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
106 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
110 void VisuGUI_DeformedShapeDlg::initFromPrsObject(VISU::DeformedShape_i* thePrs) {
111 myScalarPane->initFromPrsObject(thePrs);
112 setFactor(thePrs->GetScale());
113 UseMagn->setChecked(thePrs->IsColored());
117 int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) {
118 myScalarPane->storeToPrsObject(thePrs);
119 thePrs->SetScale(getFactor());
120 thePrs->ShowColored(isColored());
125 void VisuGUI_DeformedShapeDlg::accept() {
126 if (myScalarPane->check()) QDialog::accept();