Salome HOME
sources v1.2c
[modules/visu.git] / src / VISUGUI / VisuGUI_MagnitudeDlg.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_MagnitudeDlg.h"
30 #include "VISU_DeformedShape_i.hh"
31
32 #include "QAD_Application.h"
33 #include "QAD_Desktop.h"
34
35 #include <qlayout.h>
36
37 using namespace std;
38
39 /*!
40   Constructor
41 */
42 VisuGUI_MagnitudeDlg::VisuGUI_MagnitudeDlg()
43     : QDialog( QAD_Application::getDesktop(), "VisuGUI_MagnitudeDlg", true, WStyle_Customize | WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu )
44 {
45   setCaption( tr( "Deformed Shape" ) );
46   setSizeGripEnabled( TRUE );
47
48   QGridLayout* TopLayout = new QGridLayout( this ); 
49   TopLayout->setSpacing( 6 );
50   TopLayout->setMargin( 11 );
51   
52   QGroupBox* TopGroup = new QGroupBox( this, "TopGroup" );
53   TopGroup->setColumnLayout(0, Qt::Vertical );
54   TopGroup->layout()->setSpacing( 0 );
55   TopGroup->layout()->setMargin( 0 );
56   QGridLayout* TopGroupLayout = new QGridLayout( TopGroup->layout() );
57   TopGroupLayout->setAlignment( Qt::AlignTop );
58   TopGroupLayout->setSpacing( 6 );
59   TopGroupLayout->setMargin( 11 );
60
61   QLabel* ScaleLabel = new QLabel( tr( "Scale Factor:" ), TopGroup, "ScaleLabel" );
62   TopGroupLayout->addWidget( ScaleLabel, 0, 0 );
63
64   ScalFact = new QAD_SpinBoxDbl( TopGroup, 0, 1.0E+38, 0.1, 5);
65   ScalFact->setValue( 0.1 );
66   TopGroupLayout->addWidget( ScalFact, 0, 1 );
67
68   UseMagn = new QCheckBox( tr( "Magnitude coloring" ), TopGroup, "UseMagn" );
69   UseMagn->setChecked( true );
70   TopGroupLayout->addMultiCellWidget( UseMagn, 1, 1, 0, 1 );
71   //if (!enableUM)
72   //  UseMagn->hide();
73
74   QGroupBox* GroupButtons = new QGroupBox( this, "GroupButtons" );
75   GroupButtons->setGeometry( QRect( 10, 10, 281, 48 ) ); 
76   GroupButtons->setColumnLayout(0, Qt::Vertical );
77   GroupButtons->layout()->setSpacing( 0 );
78   GroupButtons->layout()->setMargin( 0 );
79   QGridLayout* GroupButtonsLayout = new QGridLayout( GroupButtons->layout() );
80   GroupButtonsLayout->setAlignment( Qt::AlignTop );
81   GroupButtonsLayout->setSpacing( 6 );
82   GroupButtonsLayout->setMargin( 11 );
83
84   QPushButton* buttonOk = new QPushButton( tr( "&OK" ), GroupButtons, "buttonOk" );
85   buttonOk->setAutoDefault( TRUE );
86   buttonOk->setDefault( TRUE );
87   GroupButtonsLayout->addWidget( buttonOk, 0, 0 );
88   GroupButtonsLayout->addItem( new QSpacerItem( 5, 5, QSizePolicy::Expanding, QSizePolicy::Minimum ), 0, 1 );
89   QPushButton* buttonCancel = new QPushButton( tr( "&Cancel" ) , GroupButtons, "buttonCancel" );
90   buttonCancel->setAutoDefault( TRUE );
91   GroupButtonsLayout->addWidget( buttonCancel, 0, 2 );
92   
93   TopLayout->addWidget( TopGroup,     0, 0 );
94   TopLayout->addWidget( GroupButtons, 1, 0 );
95
96   // signals and slots connections
97   connect( buttonOk,     SIGNAL( clicked() ), this, SLOT( accept() ) );
98   connect( buttonCancel, SIGNAL( clicked() ), this, SLOT( reject() ) );
99 }
100
101 /*!
102   Destructor
103 */
104 VisuGUI_MagnitudeDlg::~VisuGUI_MagnitudeDlg()
105 {
106 }
107
108
109 void VisuGUI_MagnitudeDlg::initFromPrsObject(VISU::DeformedShape_i* thePrs) {
110   setFactor(thePrs->GetScale());
111   UseMagn->setChecked(thePrs->IsColored());
112 }
113
114
115 void VisuGUI_MagnitudeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) {
116   thePrs->SetScale(getFactor());
117   thePrs->ShowColored(isColored());
118 }
119