1 // Copyright (C) 2007-2013 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.
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
19 // GEOM RepairGUI : GUI for Geometry component
20 // File : RepairGUI_RemoveWebsDlg.cxx
22 #include "RepairGUI_RemoveWebsDlg.h"
25 #include <GeometryGUI.h>
28 #include <SalomeApp_Application.h>
29 #include <LightApp_SelectionMgr.h>
30 #include <SUIT_Session.h>
31 #include <SUIT_ResourceMgr.h>
33 #include <GEOMImpl_Types.hxx>
35 #include <TColStd_MapOfInteger.hxx>
37 //=================================================================================
38 // class : RepairGUI_RemoveWebsDlg()
39 // purpose : Constructs a RepairGUI_RemoveWebsDlg which is a child of 'parent', with the
40 // name 'name' and widget flags set to 'f'.
41 // The dialog will by default be modeless, unless you set 'modal' to
42 // TRUE to construct a modal dialog.
43 //=================================================================================
44 RepairGUI_RemoveWebsDlg::RepairGUI_RemoveWebsDlg (GeometryGUI* theGeometryGUI, QWidget* parent,
46 : GEOMBase_Skeleton(theGeometryGUI, parent, modal)
48 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
49 QPixmap image0 (aResMgr->loadPixmap("GEOM", tr("ICON_DLG_REMOVE_WEBS")));
50 QPixmap image1 (aResMgr->loadPixmap("GEOM", tr("ICON_SELECT")));
52 setWindowTitle(tr("GEOM_REMOVE_WEBS_TITLE"));
54 /***************************************************************/
55 mainFrame()->GroupConstructors->setTitle(tr("GEOM_REMOVE_WEBS_TITLE"));
56 mainFrame()->RadioButton1->setIcon( image0 );
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_REMOVE_WEBS" ) );
65 GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
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 );
73 /***************************************************************/
75 setHelpFileName( "remove_webs_operation_page.html" );
80 //=================================================================================
81 // function : ~RepairGUI_RemoveWebsDlg()
82 // purpose : Destroys the object and frees any allocated resources
83 //=================================================================================
84 RepairGUI_RemoveWebsDlg::~RepairGUI_RemoveWebsDlg()
88 //=================================================================================
91 //=================================================================================
92 void RepairGUI_RemoveWebsDlg::Init()
95 myEditCurrentArgument = GroupPoints->LineEdit1;
101 mainFrame()->GroupBoxPublish->show();
102 //Hide preview checkbox
103 mainFrame()->CheckBoxPreview->hide();
105 /* signals and slots connections */
106 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
107 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
109 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
110 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
112 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
113 this, SLOT(SelectionIntoArgument()));
115 initName(tr("REMOVE_WEBS_NEW_OBJ_NAME"));
117 SelectionIntoArgument();
120 //=================================================================================
121 // function : ClickOnOk()
122 // purpose : Same than click on apply but close this dialog.
123 //=================================================================================
124 void RepairGUI_RemoveWebsDlg::ClickOnOk()
126 setIsApplyAndClose(true);
131 //=================================================================================
132 // function : ClickOnApply()
134 //=================================================================================
135 bool RepairGUI_RemoveWebsDlg::ClickOnApply()
142 myEditCurrentArgument->setText("");
143 myObject = GEOM::GEOM_Object::_nil();
152 //=================================================================================
153 // function : SelectionIntoArgument()
154 // purpose : Called when selection as changed or other case
155 // : used only by SelectButtonC1A1 (LineEditC1A1)
156 //=================================================================================
157 void RepairGUI_RemoveWebsDlg::SelectionIntoArgument()
159 myEditCurrentArgument->setText( "" );
162 LightApp_SelectionMgr* aSelMgr = myGeomGUI->getApp()->selectionMgr();
163 SALOME_ListIO aSelList;
164 aSelMgr->selectedObjects(aSelList);
166 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
167 if (aSelList.Extent() != 1) {
168 if (myEditCurrentArgument == GroupPoints->LineEdit1)
175 GEOM::GEOM_Object_ptr aSelectedObject =
176 GEOMBase::ConvertIOinGEOMObject(aSelList.First());
178 if (CORBA::is_nil(aSelectedObject))
181 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
182 myObject = aSelectedObject;
186 myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject));
189 //=================================================================================
190 // function : SetEditCurrentArgument()
192 //=================================================================================
193 void RepairGUI_RemoveWebsDlg::SetEditCurrentArgument()
195 if (sender() == GroupPoints->PushButton1) {
196 GroupPoints->LineEdit1->setFocus();
197 myEditCurrentArgument = GroupPoints->LineEdit1;
199 SelectionIntoArgument();
202 //=================================================================================
203 // function : LineEditReturnPressed()
205 //=================================================================================
206 void RepairGUI_RemoveWebsDlg::LineEditReturnPressed()
208 if (sender() == GroupPoints->LineEdit1) {
209 myEditCurrentArgument = GroupPoints->LineEdit1;
210 GEOMBase_Skeleton::LineEditReturnPressed();
214 //=================================================================================
215 // function : ActivateThisDialog()
217 //=================================================================================
218 void RepairGUI_RemoveWebsDlg::ActivateThisDialog()
220 GEOMBase_Skeleton::ActivateThisDialog();
221 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
222 this, SLOT(SelectionIntoArgument()));
227 //=================================================================================
228 // function : enterEvent()
229 // purpose : Mouse enter onto the dialog to activate it
230 //=================================================================================
231 void RepairGUI_RemoveWebsDlg::enterEvent (QEvent* e)
233 if (!mainFrame()->GroupConstructors->isEnabled())
234 ActivateThisDialog();
237 //=================================================================================
238 // function : activateSelection
239 // purpose : activate selection of solids and compounds
240 //=================================================================================
241 void RepairGUI_RemoveWebsDlg::activateSelection()
243 TColStd_MapOfInteger aTypes;
244 //aTypes.Add( GEOM_SOLID );
245 aTypes.Add( GEOM_COMPOUND );
246 globalSelection( aTypes );
249 //=================================================================================
250 // function : createOperation
252 //=================================================================================
253 GEOM::GEOM_IOperations_ptr RepairGUI_RemoveWebsDlg::createOperation()
255 return getGeomEngine()->GetIHealingOperations(getStudyId());
258 //=================================================================================
259 // function : isValid
261 //=================================================================================
262 bool RepairGUI_RemoveWebsDlg::isValid (QString& msg)
267 //=================================================================================
268 // function : execute
270 //=================================================================================
271 bool RepairGUI_RemoveWebsDlg::execute (ObjectList& objects)
273 GEOM::GEOM_IHealingOperations_var anOper = GEOM::GEOM_IHealingOperations::_narrow(getOperation());
274 GEOM::GEOM_Object_var anObj = anOper->RemoveInternalFaces(myObject);
276 if (!anObj->_is_nil())
277 objects.push_back(anObj._retn());
282 //=================================================================================
283 // function : restoreSubShapes
285 //=================================================================================
286 void RepairGUI_RemoveWebsDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
287 SALOMEDS::SObject_ptr theSObject)
289 if (mainFrame()->CheckBoxRestoreSS->isChecked()) {
290 // empty list of arguments means that all arguments should be restored
291 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
292 /*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GetInPlaceByHistory
293 /*theInheritFirstArg=*/true,
294 mainFrame()->CheckBoxAddPrefix->isChecked());