1 // GEOM RepairGUI : GUI for Geometry component
3 // Copyright (C) 2003 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
24 // File : RepairGUI_RemoveExtraEdgesDlg.cxx
25 // Author : Michael Zorin
29 #include "RepairGUI_RemoveExtraEdgesDlg.h"
31 #include "SalomeApp_Application.h"
32 #include "LightApp_SelectionMgr.h"
33 #include "SUIT_Session.h"
35 #include "GEOMImpl_Types.hxx"
37 #include <TColStd_MapOfInteger.hxx>
40 #include <qcheckbox.h>
42 //=================================================================================
43 // class : RepairGUI_RemoveExtraEdgesDlg()
44 // purpose : Constructs a RepairGUI_RemoveExtraEdgesDlg which is a child of 'parent', with the
45 // name 'name' and widget flags set to 'f'.
46 // The dialog will by default be modeless, unless you set 'modal' to
47 // TRUE to construct a modal dialog.
48 //=================================================================================
49 RepairGUI_RemoveExtraEdgesDlg::RepairGUI_RemoveExtraEdgesDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
50 const char* name, bool modal, WFlags fl)
51 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
52 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
54 SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
55 QPixmap image0(aResMgr->loadPixmap("GEOM",tr("ICON_DLG_REMOVE_EXTRA_EDGES")));
56 QPixmap image1(aResMgr->loadPixmap("GEOM",tr("ICON_SELECT")));
58 setCaption(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
60 /***************************************************************/
61 GroupConstructors->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
62 RadioButton1->setPixmap(image0);
63 RadioButton2->close(TRUE);
64 RadioButton3->close(TRUE);
66 GroupPoints = new DlgRef_1Sel_QTD(this, "GroupPoints");
67 GroupPoints->GroupBox1->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES"));
68 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
69 GroupPoints->PushButton1->setPixmap(image1);
70 GroupPoints->LineEdit1->setReadOnly( true );
72 Layout1->addWidget(GroupPoints, 2, 0);
73 /***************************************************************/
75 setHelpFileName("remove_extra_edges_operation_page.html");
81 //=================================================================================
82 // function : ~RepairGUI_RemoveExtraEdgesDlg()
83 // purpose : Destroys the object and frees any allocated resources
84 //=================================================================================
85 RepairGUI_RemoveExtraEdgesDlg::~RepairGUI_RemoveExtraEdgesDlg()
90 //=================================================================================
93 //=================================================================================
94 void RepairGUI_RemoveExtraEdgesDlg::Init()
97 myEditCurrentArgument = GroupPoints->LineEdit1;
103 GroupBoxPublish->show();
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_EXTRA_EDGES_NEW_OBJ_NAME" ) );
119 //=================================================================================
120 // function : ClickOnOk()
121 // purpose : Same than click on apply but close this dialog.
122 //=================================================================================
123 void RepairGUI_RemoveExtraEdgesDlg::ClickOnOk()
125 if ( ClickOnApply() )
129 //=================================================================================
130 // function : ClickOnApply()
132 //=================================================================================
133 bool RepairGUI_RemoveExtraEdgesDlg::ClickOnApply()
140 myEditCurrentArgument->setText("");
141 myObject = GEOM::GEOM_Object::_nil();
151 //=================================================================================
152 // function : SelectionIntoArgument()
153 // purpose : Called when selection as changed or other case
154 // : used only by SelectButtonC1A1 (LineEditC1A1)
155 //=================================================================================
156 void RepairGUI_RemoveExtraEdgesDlg::SelectionIntoArgument()
158 myEditCurrentArgument->setText("");
161 if(myEditCurrentArgument == GroupPoints->LineEdit1) {
162 if (IObjectCount() != 1) {
163 if (myEditCurrentArgument == GroupPoints->LineEdit1)
170 Standard_Boolean testResult = Standard_False;
171 GEOM::GEOM_Object_ptr aSelectedObject =
172 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
177 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
178 myObject = aSelectedObject;
182 myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
185 //=================================================================================
186 // function : SetEditCurrentArgument()
188 //=================================================================================
189 void RepairGUI_RemoveExtraEdgesDlg::SetEditCurrentArgument()
191 if( sender() == GroupPoints->PushButton1 )
193 GroupPoints->LineEdit1->setFocus();
194 myEditCurrentArgument = GroupPoints->LineEdit1;
196 SelectionIntoArgument();
200 //=================================================================================
201 // function : LineEditReturnPressed()
203 //=================================================================================
204 void RepairGUI_RemoveExtraEdgesDlg::LineEditReturnPressed()
206 if( sender() == GroupPoints->LineEdit1 )
208 myEditCurrentArgument = GroupPoints->LineEdit1;
209 GEOMBase_Skeleton::LineEditReturnPressed();
214 //=================================================================================
215 // function : ActivateThisDialog()
217 //=================================================================================
218 void RepairGUI_RemoveExtraEdgesDlg::ActivateThisDialog()
220 GEOMBase_Skeleton::ActivateThisDialog();
221 connect(myGeomGUI->getApp()->selectionMgr(), SIGNAL(currentSelectionChanged()),
222 this, SLOT(SelectionIntoArgument()));
228 //=================================================================================
229 // function : enterEvent()
230 // purpose : Mouse enter onto the dialog to activate it
231 //=================================================================================
232 void RepairGUI_RemoveExtraEdgesDlg::enterEvent(QEvent* e)
234 if ( !GroupConstructors->isEnabled() )
235 ActivateThisDialog();
239 //=================================================================================
240 // function : closeEvent()
242 //=================================================================================
243 void RepairGUI_RemoveExtraEdgesDlg::closeEvent(QCloseEvent* e)
245 GEOMBase_Skeleton::closeEvent( e );
248 //=================================================================================
249 // function : activateSelection
250 // purpose : activate selection of solids and compounds
251 //=================================================================================
252 void RepairGUI_RemoveExtraEdgesDlg::activateSelection()
254 TColStd_MapOfInteger aTypes;
255 aTypes.Add( GEOM_SOLID );
256 aTypes.Add( GEOM_COMPOUND );
257 globalSelection( aTypes );
260 //=================================================================================
261 // function : createOperation
263 //=================================================================================
264 GEOM::GEOM_IOperations_ptr RepairGUI_RemoveExtraEdgesDlg::createOperation()
266 return getGeomEngine()->GetIBlocksOperations( getStudyId() );
269 //=================================================================================
270 // function : isValid
272 //=================================================================================
273 bool RepairGUI_RemoveExtraEdgesDlg::isValid( QString& msg )
278 //=================================================================================
279 // function : execute
281 //=================================================================================
282 bool RepairGUI_RemoveExtraEdgesDlg::execute( ObjectList& objects )
284 GEOM::GEOM_Object_var anObj;
286 anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->RemoveExtraEdges(myObject);
288 if ( !anObj->_is_nil() )
289 objects.push_back( anObj._retn() );
294 //=================================================================================
295 // function : restoreSubShapes
297 //=================================================================================
298 void RepairGUI_RemoveExtraEdgesDlg::restoreSubShapes (SALOMEDS::Study_ptr theStudy,
299 SALOMEDS::SObject_ptr theSObject)
301 if (CheckBoxRestoreSS->isChecked()) {
302 // empty list of arguments means that all arguments should be restored
303 getGeomEngine()->RestoreSubShapesSO(theStudy, theSObject, GEOM::ListOfGO(),
304 /*theFindMethod=*/GEOM::FSM_GetInPlace, // ? GetInPlaceByHistory
305 /*theInheritFirstArg=*/true);