1 // Copyright (C) 2007-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 // GEOM RepairGUI : GUI for Geometry component
21 // File : RepairGUI_RemoveWebsDlg.cxx
23 #include "RepairGUI_RemoveWebsDlg.h"
26 #include <GeometryGUI.h>
29 #include <SalomeApp_Application.h>
30 #include <LightApp_SelectionMgr.h>
31 #include <SUIT_Session.h>
32 #include <SUIT_ResourceMgr.h>
34 #include <GEOMImpl_Types.hxx>
36 #include <TColStd_MapOfInteger.hxx>
38 //=================================================================================
39 // class : RepairGUI_RemoveWebsDlg()
40 // purpose : Constructs a RepairGUI_RemoveWebsDlg which is a child of 'parent', with the
41 // name 'name' and widget flags set to 'f'.
42 // The dialog will by default be modeless, unless you set 'modal' to
43 // TRUE to construct a modal dialog.
44 //=================================================================================
45 RepairGUI_RemoveWebsDlg::RepairGUI_RemoveWebsDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
47 : GEOMBase_Skeleton(theGeometryGUI, parent, modal)
49 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
50 QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_REMOVE_WEBS")));
51 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
53 setWindowTitle(tr("GEOM_REMOVE_WEBS_TITLE"));
55 /***************************************************************/
56 mainFrame()->GroupConstructors->setTitle(tr("GEOM_REMOVE_WEBS_TITLE"));
57 mainFrame()->RadioButton1->setIcon( image0 );
58 mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
59 mainFrame()->RadioButton2->close();
60 mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
61 mainFrame()->RadioButton3->close();
63 GroupPoints = new DlgRef_1Sel( centralWidget() );
65 GroupPoints->GroupBox1->setTitle( tr( "GEOM_REMOVE_WEBS" ) );
66 GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
67 GroupPoints->PushButton1->setIcon( image1 );
68 GroupPoints->LineEdit1->setReadOnly( true );
70 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
71 layout->setMargin( 0 ); layout->setSpacing( 6 );
72 layout->addWidget( GroupPoints );
74 /***************************************************************/
76 setHelpFileName( "remove_webs_operation_page.html" );
81 //=================================================================================
82 // function : ~RepairGUI_RemoveWebsDlg()
83 // purpose : Destroys the object and frees any allocated resources
84 //=================================================================================
85 RepairGUI_RemoveWebsDlg::~RepairGUI_RemoveWebsDlg()
89 //=================================================================================
92 //=================================================================================
93 void RepairGUI_RemoveWebsDlg::Init()
96 myEditCurrentArgument = GroupPoints->LineEdit1;
102 mainFrame()->GroupBoxPublish->show();
103 //Hide preview checkbox
104 mainFrame()->CheckBoxPreview->hide();
106 /* signals and slots connections */
107 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
108 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
110 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
111 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
113 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
114 this, SLOT(SelectionIntoArgument()));
116 initName(tr("REMOVE_WEBS_NEW_OBJ_NAME"));
118 SelectionIntoArgument();
121 //=================================================================================
122 // function : ClickOnOk()
123 // purpose : Same than click on apply but close this dialog.
124 //=================================================================================
125 void RepairGUI_RemoveWebsDlg::ClickOnOk()
127 setIsApplyAndClose(true);
132 //=================================================================================
133 // function : ClickOnApply()
135 //=================================================================================
136 bool RepairGUI_RemoveWebsDlg::ClickOnApply()
143 myEditCurrentArgument->setText("");
144 myObject = GEOM::GEOM_Object::_nil();
153 //=================================================================================
154 // function : SelectionIntoArgument()
155 // purpose : Called when selection as changed or other case
156 // : used only by SelectButtonC1A1 (LineEditC1A1)
157 //=================================================================================
158 void RepairGUI_RemoveWebsDlg::SelectionIntoArgument()
160 myEditCurrentArgument->setText( "" );
163 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
164 SALOME_ListIO aSelList;
165 aSelMgr->selectedObjects(aSelList);
167 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
168 if (aSelList.Extent() != 1) {
169 if (myEditCurrentArgument == GroupPoints->LineEdit1)
176 GEOM::GEOM_Object_ptr aSelectedObject =
177 GEOMBase::ConvertIOinGEOMObject(aSelList.First());
179 if (CORBA::is_nil(aSelectedObject))
182 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
183 myObject = aSelectedObject;
187 myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
190 //=================================================================================
191 // function : SetEditCurrentArgument()
193 //=================================================================================
194 void RepairGUI_RemoveWebsDlg::SetEditCurrentArgument()
196 if (sender() == GroupPoints->PushButton1) {
197 GroupPoints->LineEdit1->setFocus();
198 myEditCurrentArgument = GroupPoints->LineEdit1;
200 SelectionIntoArgument();
203 //=================================================================================
204 // function : LineEditReturnPressed()
206 //=================================================================================
207 void RepairGUI_RemoveWebsDlg::LineEditReturnPressed()
209 if (sender() == GroupPoints->LineEdit1) {
210 myEditCurrentArgument = GroupPoints->LineEdit1;
211 GEOMBase_Skeleton::LineEditReturnPressed();
215 //=================================================================================
216 // function : ActivateThisDialog()
218 //=================================================================================
219 void RepairGUI_RemoveWebsDlg::ActivateThisDialog()
221 GEOMBase_Skeleton::ActivateThisDialog();
222 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
223 this, SLOT(SelectionIntoArgument()));
228 //=================================================================================
229 // function : enterEvent()
230 // purpose : Mouse enter onto the dialog to activate it
231 //=================================================================================
232 void RepairGUI_RemoveWebsDlg::enterEvent (QEvent* e)
234 if (!mainFrame()->GroupConstructors->isEnabled())
235 ActivateThisDialog();
238 //=================================================================================
239 // function : activateSelection
240 // purpose : activate selection of solids and compounds
241 //=================================================================================
242 void RepairGUI_RemoveWebsDlg::activateSelection()
244 TColStd_MapOfInteger aTypes;
245 //aTypes.Add( GEOM_SOLID );
246 aTypes.Add( GEOM_COMPOUND );
247 globalSelection( aTypes );
250 //=================================================================================
251 // function : createOperation
253 //=================================================================================
254 GEOM::GEOM_IOperations_ptr RepairGUI_RemoveWebsDlg::createOperation()
256 return getGeomEngine()->GetIHealingOperations(getStudyId());
259 //=================================================================================
260 // function : isValid
262 //=================================================================================
263 bool RepairGUI_RemoveWebsDlg::isValid (QString& msg)
268 //=================================================================================
269 // function : execute
271 //=================================================================================
272 bool RepairGUI_RemoveWebsDlg::execute (ObjectList& objects)
274 GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
275 GEOM::GEOM_Object_var anObj = anOper->RemoveInternalFaces(myObject);
277 if (!anObj->_is_nil())
278 objects.push_back(anObj._retn());
283 //=================================================================================
284 // function : restoreSubShapes
286 //=================================================================================
287 void RepairGUI_RemoveWebsDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
288 SALOMEDS::SObject_ptr theSObject)
290 if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
291 // empty list of arguments means that all arguments should be restored
292 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
293 /*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GetInPlaceByHistory
294 /*theInheritFirstArg=*/true,
295 mainFrame()->CheckBoxAddPrefix->isChecked());