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 #include "AdvancedGUI_DividedDiskDlg.h"
25 #include <GeometryGUI.h>
28 #include <SUIT_Session.h>
29 #include <SUIT_ResourceMgr.h>
30 #include <SalomeApp_Application.h>
31 #include <LightApp_SelectionMgr.h>
34 #include <TopoDS_Shape.hxx>
37 #include <TColStd_IndexedMapOfInteger.hxx>
38 #include <TopTools_IndexedMapOfShape.hxx>
40 #include <GEOMImpl_Types.hxx>
42 //=================================================================================
44 //=================================================================================
45 AdvancedGUI_DividedDiskDlg::AdvancedGUI_DividedDiskDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
46 : GEOMBase_Skeleton(theGeometryGUI, parent, false)
48 QPixmap imageOp (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_DIVIDEDDISK_R_RATIO")));
49 QPixmap imageSel (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
51 setWindowTitle(tr("GEOM_DIVIDEDDISK_TITLE"));
53 /***************************************************************/
54 mainFrame()->GroupConstructors->setTitle(tr("GEOM_DIVIDEDDISK"));
55 mainFrame()->RadioButton1->setIcon(imageOp);
56 mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
57 mainFrame()->RadioButton2->close();
58 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
59 mainFrame()->RadioButton3->close();
61 GroupParams = new DlgRef_1Spin(centralWidget());
62 GroupParams->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
63 GroupParams->TextLabel1->setText(tr("GEOM_RADIUS"));
65 GroupOrientation = new DlgRef_3Radio(centralWidget());
66 GroupOrientation->GroupBox1->setTitle(tr("GEOM_ORIENTATION"));
67 GroupOrientation->RadioButton1->setText(tr("GEOM_WPLANE_OXY"));
68 GroupOrientation->RadioButton2->setText(tr("GEOM_WPLANE_OYZ"));
69 GroupOrientation->RadioButton3->setText(tr("GEOM_WPLANE_OZX"));
70 //@@ setup dialog box layout here @@//
72 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
73 layout->setMargin(0); layout->setSpacing(6);
74 layout->addWidget(GroupParams);
75 layout->addWidget(GroupOrientation);
76 /***************************************************************/
78 setHelpFileName("create_divideddisk_page.html");
83 //=================================================================================
85 //=================================================================================
86 AdvancedGUI_DividedDiskDlg::~AdvancedGUI_DividedDiskDlg()
88 // no need to delete child widgets, Qt does it all for us
91 //=================================================================================
94 //=================================================================================
95 void AdvancedGUI_DividedDiskDlg::Init()
97 // Get setting of step value from file configuration
98 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
99 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
101 // min, max, step and decimals for spin boxes & initial values
102 initSpinBox(GroupParams->SpinBox_DX, 0.00001, COORD_MAX, step, "length_precision" );
103 GroupParams->SpinBox_DX->setValue(100);
105 GroupOrientation->RadioButton1->setChecked(true);
108 // Signal/slot connections
109 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
110 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
111 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
112 this, SLOT(SetDoubleSpinBoxStep(double)));
114 connect(GroupParams->SpinBox_DX, SIGNAL(valueChanged(double)), this, SLOT(ValueChangedInSpinBox()));
116 connect(GroupOrientation->RadioButton1, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
117 connect(GroupOrientation->RadioButton2, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
118 connect(GroupOrientation->RadioButton3, SIGNAL(clicked()), this, SLOT(RadioButtonClicked()));
120 initName(tr("GEOM_DIVIDEDDISK"));
122 resize(minimumSizeHint());
123 displayPreview(true);
126 //=================================================================================
127 // function : SetDoubleSpinBoxStep()
128 // purpose : Double spin box management
129 //=================================================================================
130 void AdvancedGUI_DividedDiskDlg::SetDoubleSpinBoxStep (double step)
132 //@@ set double spin box step for all spin boxes here @@//
135 //=================================================================================
136 // function : ClickOnOk()
138 //=================================================================================
139 void AdvancedGUI_DividedDiskDlg::ClickOnOk()
145 //=================================================================================
146 // function : ClickOnApply()
148 //=================================================================================
149 bool AdvancedGUI_DividedDiskDlg::ClickOnApply()
159 //=================================================================================
160 // function : ActivateThisDialog()
162 //=================================================================================
163 void AdvancedGUI_DividedDiskDlg::ActivateThisDialog()
165 GEOMBase_Skeleton::ActivateThisDialog();
166 displayPreview(true);
169 //=================================================================================
170 // function : enterEvent [REDEFINED]
172 //=================================================================================
173 void AdvancedGUI_DividedDiskDlg::enterEvent (QEvent*)
175 if (!mainFrame()->GroupConstructors->isEnabled())
176 ActivateThisDialog();
179 //=================================================================================
180 // function : RadioBittonClicked()
181 // purpose : Radio button management
182 //=================================================================================
183 void AdvancedGUI_DividedDiskDlg::RadioButtonClicked()
185 if (GroupOrientation->RadioButton1->isChecked())
187 else if (GroupOrientation->RadioButton2->isChecked())
189 else if (GroupOrientation->RadioButton3->isChecked())
192 // gp_Pnt theOrigin = gp::Origin();
193 // gp_Dir DirZ = gp::DZ();
194 // gp_Dir DirX = gp::DX();
195 // gp_Dir DirY = gp::DY();
197 // if (GroupOrientation->RadioButton1->isChecked())
198 // myWPlane = gp_Ax3(theOrigin, DirZ, DirX);
199 // else if (GroupOrientation->RadioButton2->isChecked())
200 // myWPlane = gp_Ax3(theOrigin, DirX, DirY);
201 // else if (GroupOrientation->RadioButton3->isChecked())
202 // myWPlane = gp_Ax3(theOrigin, DirY, DirZ);
204 displayPreview(true);
207 //=================================================================================
208 // function : ValueChangedInSpinBox()
210 //=================================================================================
211 void AdvancedGUI_DividedDiskDlg::ValueChangedInSpinBox()
213 //@@ connect custom spin boxes or other widget to this slot in the Init() method for automatic preview update @@//
214 displayPreview(true);
217 //=================================================================================
218 // function : createOperation
220 //=================================================================================
221 GEOM::GEOM_IOperations_ptr AdvancedGUI_DividedDiskDlg::createOperation()
223 return getGeomEngine()->GetIAdvancedOperations(getStudyId());
226 //=================================================================================
227 // function : isValid
229 //=================================================================================
230 bool AdvancedGUI_DividedDiskDlg::isValid (QString& msg)
234 //@@ add custom validation actions here @@//
239 //=================================================================================
240 // function : execute
242 //=================================================================================
243 bool AdvancedGUI_DividedDiskDlg::execute (ObjectList& objects)
247 GEOM::GEOM_Object_var anObj;
249 GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation());
251 //@@ retrieve input values from the widgets here @@//
252 CORBA::Double theR = GroupParams->SpinBox_DX->value(); //@@ init parameter value from dialog box @@;
253 CORBA::Double theRatio = 50; //@@ init parameter value from dialog box @@;
255 // call engine function
256 anObj = anOper->MakeDividedDisk(theR, theRatio, myOrientation);
257 res = !anObj->_is_nil();
258 if (res && !IsPreview())
260 QStringList aParameters;
261 //@@ put stringified input parameters to the string list here to store in the data model for notebook @@//
262 //aParameters << @@ stringified parameter value @@; // R parameter
263 //aParameters << @@ stringified parameter value @@; // Ratio parameter
264 if ( aParameters.count() > 0 ) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
268 objects.push_back(anObj._retn());