1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 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.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // GEOM GEOMGUI : GUI for Geometry component
23 // File : GEOMToolsGUI_DeflectionDlg.cxx
26 #include "GEOMToolsGUI_DeflectionDlg.h"
27 #include <GeometryGUI.h>
28 #include <LightApp_Application.h>
29 #include <SalomeApp_DoubleSpinBox.h>
31 #include <SUIT_MessageBox.h>
32 #include <SUIT_ResourceMgr.h>
33 #include <SUIT_Session.h>
34 #include <SUIT_Tools.h>
37 #include <QPushButton>
39 #include <QGridLayout>
42 //=================================================================================
43 // class : GEOMToolsGUI_DeflectionDlg()
44 // purpose : Constructs a GEOMToolsGUI_DeflectionDlg which is a child of 'parent', with the
45 // name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // TRUE to construct a modal dialog.
48 //=================================================================================
49 GEOMToolsGUI_DeflectionDlg::GEOMToolsGUI_DeflectionDlg (QWidget* parent)
50 : QDialog(parent, Qt::WindowTitleHint | Qt::WindowSystemMenuHint)
52 setObjectName("GEOMToolsGUI_DeflectionDlg");
55 setWindowTitle(tr("GEOM_DEFLECTION_TLT"));
56 setSizeGripEnabled(TRUE);
57 QGridLayout* MyDialogLayout = new QGridLayout(this);
58 MyDialogLayout->setSpacing(6);
59 MyDialogLayout->setMargin(11);
61 /***************************************************************/
62 QGroupBox* GroupC1 = new QGroupBox (this);
63 GroupC1->setObjectName("GroupC1");
64 QGridLayout* GroupC1Layout = new QGridLayout (GroupC1);
65 GroupC1Layout->setAlignment(Qt::AlignTop);
66 GroupC1Layout->setSpacing(6);
67 GroupC1Layout->setMargin(11);
69 QLabel* TextLabel1 = new QLabel (GroupC1);
70 TextLabel1->setObjectName("TextLabel1");
71 TextLabel1->setText(tr("GEOM_DEFLECTION"));
72 GroupC1Layout->addWidget(TextLabel1, 0, 0);
74 SpinBox = new SalomeApp_DoubleSpinBox (GroupC1);
75 // Obtain precision from preferences
76 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
77 int aPrecision = resMgr->integerValue( "Geometry", "parametric_precision", 6 );
78 SpinBox->setAcceptNames( false );
79 SpinBox->setPrecision( aPrecision );
80 SpinBox->setDecimals( aPrecision );
81 SpinBox->setRange( DEFLECTION_MIN, 1.0 );
82 SpinBox->setSingleStep( 1.0e-04 );
83 SpinBox->setObjectName("SpinBoxU");
84 SpinBox->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
85 SpinBox->setValue(1.0e-04);
86 GroupC1Layout->addWidget(SpinBox, 0, 1);
88 /***************************************************************/
89 QGroupBox* GroupButtons = new QGroupBox (this);
90 GroupButtons->setObjectName("GroupButtons");
91 QGridLayout* GroupButtonsLayout = new QGridLayout (GroupButtons);
92 GroupButtonsLayout->setAlignment(Qt::AlignTop);
93 GroupButtonsLayout->setSpacing(6);
94 GroupButtonsLayout->setMargin(11);
96 QPushButton* buttonOk = new QPushButton (GroupButtons);
97 buttonOk->setObjectName("buttonOk");
98 buttonOk->setText(tr("GEOM_BUT_OK"));
99 buttonOk->setAutoDefault(TRUE);
100 buttonOk->setDefault(TRUE);
101 GroupButtonsLayout->addWidget(buttonOk, 0, 0);
103 GroupButtonsLayout->addItem(new QSpacerItem (20, 20, QSizePolicy::Expanding, QSizePolicy::Minimum), 0, 1);
105 QPushButton* buttonCancel = new QPushButton (GroupButtons);
106 buttonCancel->setObjectName("buttonCancel");
107 buttonCancel->setText(tr("GEOM_BUT_CANCEL"));
108 buttonCancel->setAutoDefault(TRUE);
109 GroupButtonsLayout->addWidget(buttonCancel, 0, 1);
111 QPushButton* buttonHelp = new QPushButton (GroupButtons);
112 buttonHelp->setObjectName("buttonHelp");
113 buttonHelp->setText(tr("GEOM_BUT_HELP"));
114 buttonHelp->setAutoDefault(TRUE);
115 GroupButtonsLayout->addWidget(buttonHelp, 0, 2);
116 /***************************************************************/
118 MyDialogLayout->addWidget(GroupC1, 0, 0);
119 MyDialogLayout->addWidget(GroupButtons, 1, 0);
121 myHelpFileName = "deflection_page.html";
123 // signals and slots connections
124 connect(buttonOk, SIGNAL(clicked()), this, SLOT(accept()));
125 connect(buttonCancel, SIGNAL(clicked()), this, SLOT(reject()));
126 connect(buttonHelp, SIGNAL(clicked()), this, SLOT(ClickOnHelp()));
128 // Move widget on the botton right corner of main widget
129 SUIT_Tools::centerWidget(this, parent);
132 //=================================================================================
133 // function : ~GEOMToolsGUI_DeflectionDlg()
134 // purpose : Destroys the object and frees any allocated resources
135 //=================================================================================
136 GEOMToolsGUI_DeflectionDlg::~GEOMToolsGUI_DeflectionDlg()
138 // no need to delete child widgets, Qt does it all for us
141 double GEOMToolsGUI_DeflectionDlg::getTheDC() const
143 return SpinBox->text().toDouble();
146 void GEOMToolsGUI_DeflectionDlg::setTheDC (const double v)
148 SpinBox->setValue(v);
151 //=================================================================================
152 // function : ClickOnHelp()
154 //=================================================================================
155 void GEOMToolsGUI_DeflectionDlg::ClickOnHelp()
157 LightApp_Application* app = (LightApp_Application*)(SUIT_Session::session()->activeApplication());
159 GeometryGUI* aGeomGUI = dynamic_cast<GeometryGUI*>(app->module("Geometry"));
160 app->onHelpContextModule(aGeomGUI ? app->moduleName(aGeomGUI->moduleName()) : QString(""), myHelpFileName);
165 platform = "winapplication";
167 platform = "application";
169 SUIT_MessageBox::warning
170 (0, QObject::tr("WRN_WARNING"),
171 QObject::tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
172 arg(app->resourceMgr()->stringValue("ExternalBrowser", platform)).arg(myHelpFileName),
173 QObject::tr("BUT_OK"));
177 //=================================================================================
178 // function : keyPressEvent()
180 //=================================================================================
181 void GEOMToolsGUI_DeflectionDlg::keyPressEvent (QKeyEvent* e)
183 QDialog::keyPressEvent(e);
187 if (e->key() == Qt::Key_F1) {