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_MagnitudeDlg.h"
30 #include "VisuGUI_Selection.h"
31 #include "VISU_DeformedShape_i.hh"
33 #include "QtxDblSpinBox.h"
35 #include "SalomeApp_Application.h"
37 #include "SUIT_Desktop.h"
40 #include <qtabwidget.h>
47 VisuGUI_MagnitudeDlg::VisuGUI_MagnitudeDlg()
48 : QDialog( VisuGUI::application()->desktop(), "VisuGUI_MagnitudeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
50 setCaption( tr( "Deformed Shape" ) );
51 setSizeGripEnabled( TRUE );
53 QVBoxLayout* TopLayout = new QVBoxLayout( this );
54 TopLayout->setSpacing( 6 );
55 TopLayout->setMargin( 11 );
57 QTabWidget* aTabBox = new QTabWidget(this);
59 QVBox* aBox = new QVBox(this);
60 aBox->setMargin( 11 );
61 QFrame* TopGroup = new QFrame( aBox, "TopGroup" );
62 TopGroup->setFrameStyle(QFrame::Box | QFrame::Sunken);
63 TopGroup->setLineWidth(1);
64 QGridLayout* TopGroupLayout = new QGridLayout( TopGroup );
65 TopGroupLayout->setAlignment( Qt::AlignTop | Qt::AlignCenter );
66 TopGroupLayout->setSpacing( 6 );
67 TopGroupLayout->setMargin( 11 );
69 QLabel* ScaleLabel = new QLabel( tr( "Scale Factor:" ), TopGroup, "ScaleLabel" );
70 TopGroupLayout->addWidget( ScaleLabel, 0, 0 );
72 ScalFact = new QtxDblSpinBox( 0, 1.0E+38, 0.1, TopGroup );
73 ScalFact->setPrecision( 5 );
74 ScalFact->setValue( 0.1 );
75 TopGroupLayout->addWidget( ScalFact, 0, 1 );
77 UseMagn = new QCheckBox( tr( "Magnitude coloring" ), TopGroup, "UseMagn" );
78 UseMagn->setChecked( true );
79 TopGroupLayout->addMultiCellWidget( UseMagn, 1, 1, 0, 1 );
82 aTabBox->addTab(aBox, "Deformed Shape");
84 myScalarPane = new VisuGUI_ScalarBarPane(this, false);
85 myScalarPane->setMargin( 5 );
86 aTabBox->addTab(myScalarPane, "Scalar Bar");
89 QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
90 GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) );
91 GroupButtons->setColumnLayout(0, Qt::Vertical );
92 GroupButtons->layout()->setSpacing( 0 );
93 GroupButtons->layout()->setMargin( 0 );
94 QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
95 GroupButtonsLayout->setAlignment( Qt::AlignTop );
96 GroupButtonsLayout->setSpacing( 6 );
97 GroupButtonsLayout->setMargin( 11 );
99 QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
100 buttonOk->setAutoDefault( TRUE );
101 buttonOk->setDefault( TRUE );
102 GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
103 GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
104 QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
105 buttonCancel->setAutoDefault( TRUE );
106 GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
108 TopLayout->addWidget( aTabBox );
109 TopLayout->addWidget( GroupButtons );
111 // signals and slots connections
112 connect( buttonOk, SIGNAL( clicked() ), this, SLOT( accept() ) );
113 connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
117 void VisuGUI_MagnitudeDlg::initFromPrsObject(VISU::DeformedShape_i* thePrs) {
118 myScalarPane->initFromPrsObject(thePrs);
119 setFactor(thePrs->GetScale());
120 UseMagn->setChecked(thePrs->IsColored());
124 int VisuGUI_MagnitudeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) {
125 myScalarPane->storeToPrsObject(thePrs);
126 thePrs->SetScale(getFactor());
127 thePrs->ShowColored(isColored());
132 void VisuGUI_MagnitudeDlg::accept() {
133 if (myScalarPane->check()) QDialog::accept();