1 // Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "AdvancedGUI_SmoothingSurfaceDlg.h"
23 #include <GeometryGUI.h>
26 #include <SUIT_Session.h>
27 #include <SUIT_ResourceMgr.h>
28 #include <SalomeApp_Application.h>
29 #include <LightApp_SelectionMgr.h>
32 #include <TopoDS_Shape.hxx>
35 #include <TColStd_IndexedMapOfInteger.hxx>
36 #include <TopTools_IndexedMapOfShape.hxx>
38 #include <GEOMImpl_Types.hxx>
40 //=================================================================================
42 //=================================================================================
43 AdvancedGUI_SmoothingSurfaceDlg::AdvancedGUI_SmoothingSurfaceDlg (GeometryGUI* theGeometryGUI, QWidget* parent)
44 : GEOMBase_Skeleton(theGeometryGUI, parent, false)
46 QPixmap imageOp (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_DLG_SMOOTHINGSURFACE_LPOINTS")));
47 QPixmap imageSel (SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
48 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
50 setWindowTitle(tr("GEOM_SMOOTHINGSURFACE_TITLE"));
52 /***************************************************************/
53 mainFrame()->GroupConstructors->setTitle(tr("GEOM_SMOOTHINGSURFACE"));
54 mainFrame()->RadioButton1->setIcon(imageOp);
55 mainFrame()->RadioButton2->setAttribute(Qt::WA_DeleteOnClose);
56 mainFrame()->RadioButton2->close();
57 mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose);
58 mainFrame()->RadioButton3->close();
60 GroupPoints = new DlgRef_1Sel( centralWidget() );
62 GroupPoints->GroupBox1->setTitle( tr( "GEOM_SMOOTHINGSURFACE_ARG" ) );
63 GroupPoints->TextLabel1->setText( tr( "GEOM_SMOOTHINGSURFACE_ARG_POINTS" ) );
64 GroupPoints->PushButton1->setIcon( image1 );
65 GroupPoints->LineEdit1->setReadOnly( true );
67 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
68 layout->setMargin(0); layout->setSpacing(6);
69 layout->addWidget(GroupPoints);
70 /***************************************************************/
72 setHelpFileName("create_smoothingsurface_page.html");
77 //=================================================================================
79 //=================================================================================
80 AdvancedGUI_SmoothingSurfaceDlg::~AdvancedGUI_SmoothingSurfaceDlg()
82 // no need to delete child widgets, Qt does it all for us
85 //=================================================================================
88 //=================================================================================
89 void AdvancedGUI_SmoothingSurfaceDlg::Init()
91 // Get setting of step value from file configuration
92 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
93 double step = resMgr->doubleValue("Geometry", "SettingsGeomStep", 100);
95 //@@ initialize dialog box widgets here @@//
97 // Signal/slot connections
98 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
99 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
100 connect(myGeomGUI, SIGNAL(SignalDefaultStepValueChanged(double)),
101 this, SLOT(SetDoubleSpinBoxStep(double)));
102 connect( myGeomGUI->getApp()->selectionMgr(),
103 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
105 initName(tr("GEOM_SMOOTHINGSURFACE"));
109 //=================================================================================
110 // function : ClickOnOk()
112 //=================================================================================
113 void AdvancedGUI_SmoothingSurfaceDlg::ClickOnOk()
119 //=================================================================================
120 // function : ClickOnApply()
122 //=================================================================================
123 bool AdvancedGUI_SmoothingSurfaceDlg::ClickOnApply()
133 //=================================================================================
134 // function : ActivateThisDialog()
136 //=================================================================================
137 void AdvancedGUI_SmoothingSurfaceDlg::ActivateThisDialog()
139 GEOMBase_Skeleton::ActivateThisDialog();
143 //=================================================================================
144 // function : enterEvent [REDEFINED]
146 //=================================================================================
147 void AdvancedGUI_SmoothingSurfaceDlg::enterEvent (QEvent*)
149 if (!mainFrame()->GroupConstructors->isEnabled())
150 ActivateThisDialog();
153 //=================================================================================
154 // function : createOperation
156 //=================================================================================
157 GEOM::GEOM_IOperations_ptr AdvancedGUI_SmoothingSurfaceDlg::createOperation()
159 //return getGeomEngine()->GetIAdvancedOperations(getStudyId());
160 return getGeomEngine()->GetPluginOperations(getStudyId(), "AdvancedEngine");
163 //=================================================================================
164 // function : isValid
166 //=================================================================================
167 bool AdvancedGUI_SmoothingSurfaceDlg::isValid (QString& msg)
171 //@@ add custom validation actions here @@//
176 //=================================================================================
177 // function : execute
179 //=================================================================================
180 bool AdvancedGUI_SmoothingSurfaceDlg::execute (ObjectList& objects)
184 GEOM::GEOM_Object_var anObj;
186 GEOM::GEOM_IAdvancedOperations_var anOper = GEOM::GEOM_IAdvancedOperations::_narrow(getOperation());
188 //@@ retrieve input values from the widgets here @@//
189 GEOM::ListOfGO_var points = new GEOM::ListOfGO();
190 points->length( myPoints.count() );
191 for ( int i = 0; i < myPoints.count(); i++ )
192 points[i] = myPoints[i].copy();
195 // call engine function
196 anObj = anOper->MakeSmoothingSurface(points);
197 res = !anObj->_is_nil();
198 if (res && !IsPreview())
200 QStringList aParameters;
201 //@@ put stringified input parameters to the string list here to store in the data model for notebook @@//
202 if ( aParameters.count() > 0 ) anObj->SetParameters(aParameters.join(":").toLatin1().constData());
206 objects.push_back(anObj._retn());
211 //=================================================================================
212 // function : SelectionIntoArgument()
213 // purpose : Called when selection as changed or other case
214 //=================================================================================
215 void AdvancedGUI_SmoothingSurfaceDlg::SelectionIntoArgument()
217 QList<GEOM::GeomObjPtr> points = getSelected( TopAbs_VERTEX, -1 );
218 GEOMBase::Synchronize( myPoints, points );
219 if ( !myPoints.isEmpty() )
220 GroupPoints->LineEdit1->setText( QString::number( myPoints.count() ) + "_" + tr( "GEOM_POINT" ) + tr( "_S_" ) );
222 GroupPoints->LineEdit1->setText( "" );
226 //=================================================================================
227 // function : SetEditCurrentArgument()
229 //=================================================================================
230 void AdvancedGUI_SmoothingSurfaceDlg::SetEditCurrentArgument()
232 if ( sender() == GroupPoints->PushButton1 )
233 myEditCurrentArgument = GroupPoints->LineEdit1;
234 myEditCurrentArgument->setFocus();
235 SelectionIntoArgument();