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"
31 #include "VisuGUI_Tools.h"
33 #include "VISU_DeformedShape_i.hh"
35 #include "SalomeApp_Module.h"
36 #include "SUIT_Desktop.h"
39 #include <qtabwidget.h>
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)
50 setCaption(tr("DLG_TITLE"));
51 setSizeGripEnabled(TRUE);
53 QVBoxLayout* TopLayout = new QVBoxLayout (this);
54 TopLayout->setSpacing(6);
55 TopLayout->setMargin(11);
57 QTabWidget* aTabBox = new QTabWidget (this);
59 // Deformed shape pane
60 QVBox* aBox = new QVBox (this);
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);
71 QLabel* ScaleLabel = new QLabel (tr("SCALE_FACTOR"), TopGroup, "ScaleLabel");
72 TopGroupLayout->addWidget(ScaleLabel, 0, 0);
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);
81 UseMagn = new QCheckBox (tr("MAGNITUDE_COLORING"), TopGroup, "UseMagn");
82 UseMagn->setChecked(true);
83 TopGroupLayout->addMultiCellWidget(UseMagn, 1, 1, 0, 1);
85 aTabBox->addTab(aBox, tr("DEFORMED_SHAPE_TAB"));
88 myScalarPane = new VisuGUI_ScalarBarPane (this, false);
89 myScalarPane->setMargin(5);
91 aTabBox->addTab(myScalarPane, tr("SCALAR_BAR_TAB"));
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);
104 QPushButton* buttonOk = new QPushButton (tr("&OK"), GroupButtons, "buttonOk");
105 buttonOk->setAutoDefault(TRUE);
106 buttonOk->setDefault(TRUE);
107 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
109 GroupButtonsLayout->addItem(new QSpacerItem (5, 5, QSizePolicy::Expanding,
110 QSizePolicy::Minimum), 0, 1);
112 QPushButton* buttonCancel = new QPushButton (tr("&Cancel") , GroupButtons, "buttonCancel");
113 buttonCancel->setAutoDefault(TRUE);
114 GroupButtonsLayout->addWidget(buttonCancel, 0, 2);
116 // Add Tab box and Buttons to the top layout
117 TopLayout->addWidget(aTabBox);
118 TopLayout->addWidget(GroupButtons);
120 // signals and slots connections
121 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
122 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
125 void VisuGUI_DeformedShapeDlg::initFromPrsObject (VISU::DeformedShape_i* thePrs)
127 myScalarPane->initFromPrsObject(thePrs);
128 setFactor(thePrs->GetScale());
129 UseMagn->setChecked(thePrs->IsColored());
132 int VisuGUI_DeformedShapeDlg::storeToPrsObject(VISU::DeformedShape_i* thePrs) {
133 myScalarPane->storeToPrsObject(thePrs);
134 thePrs->SetScale(getFactor());
135 thePrs->ShowColored(isColored());
139 void VisuGUI_DeformedShapeDlg::accept() {
140 if (myScalarPane->check()) QDialog::accept();