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_SmoothingSurfaceDlg.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_SmoothingSurfaceDlg::AdvancedGUI_SmoothingSurfaceDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
46 : GEOMBase_Skeleton(theGeometryGUI, parent, false)
48 QPixmap imageOp (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SMOOTHINGSURFACE_LPOINTS")));
49 QPixmap imageSel (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
50 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
52 setWindowTitle(tr("GEOM_SMOOTHINGSURFACE_TITLE"));
54 /***************************************************************/
55 mainFrame()->GroupConstructors->setTitle(tr("GEOM_SMOOTHINGSURFACE"));
56 mainFrame()->RadioButton1->setIcon(imageOp);
57 mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
58 mainFrame()->RadioButton2->close();
59 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
60 mainFrame()->RadioButton3->close();
62 GroupPoints = new DlgRef_1Sel( centralWidget() );
64 GroupPoints->GroupBox1->setTitle( tr( "GEOM_SMOOTHINGSURFACE_ARG" ) );
65 GroupPoints->TextLabel1->setText( tr( "GEOM_SMOOTHINGSURFACE_ARG_POINTS" ) );
66 GroupPoints->PushButton1->setIcon( image1 );
67 GroupPoints->LineEdit1->setReadOnly( true );
69 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
70 layout->setMargin(0); layout->setSpacing(6);
71 layout->addWidget(GroupPoints);
72 /***************************************************************/
74 setHelpFileName("create_smoothingsurface_page.html");
79 //=================================================================================
81 //=================================================================================
82 AdvancedGUI_SmoothingSurfaceDlg::~AdvancedGUI_SmoothingSurfaceDlg()
84 // no need to delete child widgets, Qt does it all for us
87 //=================================================================================
90 //=================================================================================
91 void AdvancedGUI_SmoothingSurfaceDlg::Init()
93 // Get setting of step value from file configuration
94 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
95 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
97 //@@ initialize dialog box widgets here @@//
99 // Signal/slot connections
100 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
101 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
102 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
103 this, SLOT(SetDoubleSpinBoxStep(double)));
104 connect( myGeomGUI->getApp()->selectionMgr(),
105 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
107 initName(tr("GEOM_SMOOTHINGSURFACE"));
111 //=================================================================================
112 // function : ClickOnOk()
114 //=================================================================================
115 void AdvancedGUI_SmoothingSurfaceDlg::ClickOnOk()
121 //=================================================================================
122 // function : ClickOnApply()
124 //=================================================================================
125 bool AdvancedGUI_SmoothingSurfaceDlg::ClickOnApply()
135 //=================================================================================
136 // function : ActivateThisDialog()
138 //=================================================================================
139 void AdvancedGUI_SmoothingSurfaceDlg::ActivateThisDialog()
141 GEOMBase_Skeleton::ActivateThisDialog();
145 //=================================================================================
146 // function : enterEvent [REDEFINED]
148 //=================================================================================
149 void AdvancedGUI_SmoothingSurfaceDlg::enterEvent (QEvent*)
151 if (!mainFrame()->GroupConstructors->isEnabled())
152 ActivateThisDialog();
155 //=================================================================================
156 // function : createOperation
158 //=================================================================================
159 GEOM::GEOM_IOperations_ptr AdvancedGUI_SmoothingSurfaceDlg::createOperation()
161 //return getGeomEngine()->GetIAdvancedOperations(getStudyId());
162 return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine");
165 //=================================================================================
166 // function : isValid
168 //=================================================================================
169 bool AdvancedGUI_SmoothingSurfaceDlg::isValid (QString& msg)
173 //@@ add custom validation actions here @@//
178 //=================================================================================
179 // function : execute
181 //=================================================================================
182 bool AdvancedGUI_SmoothingSurfaceDlg::execute (ObjectList& objects)
186 GEOM::GEOM_Object_var anObj;
188 GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation());
190 //@@ retrieve input values from the widgets here @@//
191 GEOM::ListOfGO_var points = new GEOM::ListOfGO();
192 points->length( myPoints.count() );
193 for ( int i = 0; i < myPoints.count(); i++ )
194 points[i] = myPoints[i].copy();
197 // call engine function
198 anObj = anOper->MakeSmoothingSurface(points);
199 res = !anObj->_is_nil();
200 if (res && !IsPreview())
202 QStringList aParameters;
203 //@@ put stringified input parameters to the string list here to store in the data model for notebook @@//
204 if ( aParameters.count() > 0 ) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
208 objects.push_back(anObj._retn());
213 //=================================================================================
214 // function : SelectionIntoArgument()
215 // purpose : Called when selection as changed or other case
216 //=================================================================================
217 void AdvancedGUI_SmoothingSurfaceDlg::SelectionIntoArgument()
219 QList<GEOM::GeomObjPtr> points = getSelected( TopAbs_VERTEX, -1 );
220 GEOMBase::Synchronize( myPoints, points );
221 if ( !myPoints.isEmpty() )
222 GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
224 GroupPoints->LineEdit1->setText( "" );
228 //=================================================================================
229 // function : SetEditCurrentArgument()
231 //=================================================================================
232 void AdvancedGUI_SmoothingSurfaceDlg::SetEditCurrentArgument()
234 if ( sender() == GroupPoints->PushButton1 )
235 myEditCurrentArgument = GroupPoints->LineEdit1;
236 myEditCurrentArgument->setFocus();
237 SelectionIntoArgument();