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 RepairGUI : GUI for Geometry component
23 // File : RepairGUI_RemoveExtraEdgesDlg.cxx
24 // Author : Michael Zorin
28 #include "RepairGUI_RemoveExtraEdgesDlg.h"
30 #include "SalomeApp_Application.h"
31 #include "LightApp_SelectionMgr.h"
32 #include "SUIT_Session.h"
34 #include "DlgRef_1Sel1Check_QTD.h"
36 #include "GEOMImpl_Types.hxx"
38 #include <TColStd_MapOfInteger.hxx>
41 #include <qcheckbox.h>
43 //=================================================================================
44 // class : RepairGUI_RemoveExtraEdgesDlg()
45 // purpose : Constructs a RepairGUI_RemoveExtraEdgesDlg which is a child of 'parent', with the
46 // name 'name' and widget flags set to 'f'.
47 // The dialog will by default be modeless, unless you set 'modal' to
48 // TRUE to construct a modal dialog.
49 //=================================================================================
50 RepairGUI_RemoveExtraEdgesDlg::RepairGUI_RemoveExtraEdgesDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
51 const char* name, bool modal, WFlags fl)
52 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
53 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
55 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
56 QPixmap image0(aResMgr->loadPixmap("GEOM",tr("ICON_DLG_REMOVE_EXTRA_EDGES")));
57 QPixmap image1(aResMgr->loadPixmap("GEOM",tr("ICON_SELECT")));
59 setCaption(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
61 /***************************************************************/
62 GroupConstructors->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
63 RadioButton1->setPixmap(image0);
64 RadioButton2->close(TRUE);
65 RadioButton3->close(TRUE);
67 GroupPoints = new DlgRef_1Sel1Check_QTD(this, "GroupPoints");
68 GroupPoints->GroupBox1->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES"));
69 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
70 GroupPoints->PushButton1->setPixmap(image1);
71 GroupPoints->LineEdit1->setReadOnly( true );
73 GroupPoints->CheckButton1->setText(tr("GEOM_RMEE_UNION_FACES"));
75 Layout1->addWidget(GroupPoints, 2, 0);
76 /***************************************************************/
78 setHelpFileName("remove_extra_edges_operation_page.html");
84 //=================================================================================
85 // function : ~RepairGUI_RemoveExtraEdgesDlg()
86 // purpose : Destroys the object and frees any allocated resources
87 //=================================================================================
88 RepairGUI_RemoveExtraEdgesDlg::~RepairGUI_RemoveExtraEdgesDlg()
93 //=================================================================================
96 //=================================================================================
97 void RepairGUI_RemoveExtraEdgesDlg::Init()
100 myEditCurrentArgument = GroupPoints->LineEdit1;
104 GroupPoints->CheckButton1->setChecked( false );
108 GroupBoxPublish->show();
110 /* signals and slots connections */
111 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
112 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
114 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
115 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
117 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
118 this, SLOT(SelectionIntoArgument()));
120 initName( tr( "REMOVE_EXTRA_EDGES_NEW_OBJ_NAME" ) );
124 //=================================================================================
125 // function : ClickOnOk()
126 // purpose : Same than click on apply but close this dialog.
127 //=================================================================================
128 void RepairGUI_RemoveExtraEdgesDlg::ClickOnOk()
130 if ( ClickOnApply() )
134 //=================================================================================
135 // function : ClickOnApply()
137 //=================================================================================
138 bool RepairGUI_RemoveExtraEdgesDlg::ClickOnApply()
145 myEditCurrentArgument->setText("");
146 myObject = GEOM::GEOM_Object::_nil();
156 //=================================================================================
157 // function : SelectionIntoArgument()
158 // purpose : Called when selection as changed or other case
159 // : used only by SelectButtonC1A1 (LineEditC1A1)
160 //=================================================================================
161 void RepairGUI_RemoveExtraEdgesDlg::SelectionIntoArgument()
163 myEditCurrentArgument->setText("");
166 if(myEditCurrentArgument == GroupPoints->LineEdit1) {
167 if (IObjectCount() != 1) {
168 if (myEditCurrentArgument == GroupPoints->LineEdit1)
175 Standard_Boolean testResult = Standard_False;
176 GEOM::GEOM_Object_ptr aSelectedObject =
177 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
182 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
183 myObject = aSelectedObject;
187 myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
190 //=================================================================================
191 // function : SetEditCurrentArgument()
193 //=================================================================================
194 void RepairGUI_RemoveExtraEdgesDlg::SetEditCurrentArgument()
196 if( sender() == GroupPoints->PushButton1 )
198 GroupPoints->LineEdit1->setFocus();
199 myEditCurrentArgument = GroupPoints->LineEdit1;
201 SelectionIntoArgument();
205 //=================================================================================
206 // function : LineEditReturnPressed()
208 //=================================================================================
209 void RepairGUI_RemoveExtraEdgesDlg::LineEditReturnPressed()
211 if( sender() == GroupPoints->LineEdit1 )
213 myEditCurrentArgument = GroupPoints->LineEdit1;
214 GEOMBase_Skeleton::LineEditReturnPressed();
219 //=================================================================================
220 // function : ActivateThisDialog()
222 //=================================================================================
223 void RepairGUI_RemoveExtraEdgesDlg::ActivateThisDialog()
225 GEOMBase_Skeleton::ActivateThisDialog();
226 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
227 this, SLOT(SelectionIntoArgument()));
233 //=================================================================================
234 // function : enterEvent()
235 // purpose : Mouse enter onto the dialog to activate it
236 //=================================================================================
237 void RepairGUI_RemoveExtraEdgesDlg::enterEvent(QEvent* e)
239 if ( !GroupConstructors->isEnabled() )
240 ActivateThisDialog();
244 //=================================================================================
245 // function : closeEvent()
247 //=================================================================================
248 void RepairGUI_RemoveExtraEdgesDlg::closeEvent(QCloseEvent* e)
250 GEOMBase_Skeleton::closeEvent( e );
253 //=================================================================================
254 // function : activateSelection
255 // purpose : activate selection of solids and compounds
256 //=================================================================================
257 void RepairGUI_RemoveExtraEdgesDlg::activateSelection()
259 TColStd_MapOfInteger aTypes;
260 aTypes.Add( GEOM_SOLID );
261 aTypes.Add( GEOM_COMPOUND );
262 globalSelection( aTypes );
265 //=================================================================================
266 // function : createOperation
268 //=================================================================================
269 GEOM::GEOM_IOperations_ptr RepairGUI_RemoveExtraEdgesDlg::createOperation()
271 return getGeomEngine()->GetIBlocksOperations( getStudyId() );
274 //=================================================================================
275 // function : isValid
277 //=================================================================================
278 bool RepairGUI_RemoveExtraEdgesDlg::isValid( QString& msg )
283 //=================================================================================
284 // function : execute
286 //=================================================================================
287 bool RepairGUI_RemoveExtraEdgesDlg::execute( ObjectList& objects )
289 GEOM::GEOM_Object_var anObj;
291 int nbFacesOptimum = -1; // -1 means do not union faces
292 if (GroupPoints->CheckButton1->isChecked())
293 nbFacesOptimum = 0; // 0 means union all faces, that possible
294 anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->RemoveExtraEdges
295 (myObject, nbFacesOptimum);
297 if (!anObj->_is_nil())
298 objects.push_back(anObj._retn());
303 //=================================================================================
304 // function : restoreSubShapes
306 //=================================================================================
307 void RepairGUI_RemoveExtraEdgesDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
308 SALOMEDS::SObject_ptr theSObject)
310 if (CheckBoxRestoreSS->isChecked()) {
311 // empty list of arguments means that all arguments should be restored
312 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
313 /*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GetInPlaceByHistory
314 /*theInheritFirstArg=*/true);