2 // This library is distributed in the hope that it will be useful,
3 // but WITHOUT ANY WARRANTY; without even the implied warranty of
4 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
5 // Lesser General Public License for more details.
7 // You should have received a copy of the GNU Lesser General Public
8 // License along with this library; if not, write to the Free Software
9 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
11 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
15 // File : RepairGUI_RemoveExtraEdgesDlg.cxx
16 // Author : Michael Zorin
20 #include "RepairGUI_RemoveExtraEdgesDlg.h"
22 #include "SalomeApp_Application.h"
23 #include "LightApp_SelectionMgr.h"
24 #include "SUIT_Session.h"
26 #include "GEOMImpl_Types.hxx"
28 #include <TColStd_MapOfInteger.hxx>
34 //=================================================================================
35 // class : RepairGUI_RemoveExtraEdgesDlg()
36 // purpose : Constructs a RepairGUI_RemoveExtraEdgesDlg which is a child of 'parent', with the
37 // name 'name' and widget flags set to 'f'.
38 // The dialog will by default be modeless, unless you set 'modal' to
39 // TRUE to construct a modal dialog.
40 //=================================================================================
41 RepairGUI_RemoveExtraEdgesDlg::RepairGUI_RemoveExtraEdgesDlg(GeometryGUI* theGeometryGUI, QWidget* parent,
42 const char* name, bool modal, WFlags fl)
43 :GEOMBase_Skeleton(theGeometryGUI, parent, name, modal, WStyle_Customize |
44 WStyle_NormalBorder | WStyle_Title | WStyle_SysMenu)
46 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_DLG_REMOVE_EXTRA_EDGES")));
47 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM",tr("ICON_SELECT")));
49 setCaption(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
51 /***************************************************************/
52 GroupConstructors->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
53 RadioButton1->setPixmap(image0);
54 RadioButton2->close(TRUE);
55 RadioButton3->close(TRUE);
57 GroupPoints = new DlgRef_1Sel_QTD(this, "GroupPoints");
58 GroupPoints->GroupBox1->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES"));
59 GroupPoints->TextLabel1->setText(tr("GEOM_SELECTED_SHAPE"));
60 GroupPoints->PushButton1->setPixmap(image1);
61 GroupPoints->LineEdit1->setReadOnly( true );
63 Layout1->addWidget(GroupPoints, 2, 0);
64 /***************************************************************/
66 setHelpFileName("remove_extra_edges_operation_page.html");
72 //=================================================================================
73 // function : ~RepairGUI_RemoveExtraEdgesDlg()
74 // purpose : Destroys the object and frees any allocated resources
75 //=================================================================================
76 RepairGUI_RemoveExtraEdgesDlg::~RepairGUI_RemoveExtraEdgesDlg()
81 //=================================================================================
84 //=================================================================================
85 void RepairGUI_RemoveExtraEdgesDlg::Init()
88 myEditCurrentArgument = GroupPoints->LineEdit1;
94 /* signals and slots connections */
95 connect(buttonOk, SIGNAL(clicked()), this, SLOT(ClickOnOk()));
96 connect(buttonApply, SIGNAL(clicked()), this, SLOT(ClickOnApply()));
98 connect(GroupPoints->PushButton1, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument()));
99 connect(GroupPoints->LineEdit1, SIGNAL(returnPressed()), this, SLOT(LineEditReturnPressed()));
101 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
102 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
104 initName( tr( "REMOVE_EXTRA_EDGES_NEW_OBJ_NAME" ) );
108 //=================================================================================
109 // function : ClickOnOk()
110 // purpose : Same than click on apply but close this dialog.
111 //=================================================================================
112 void RepairGUI_RemoveExtraEdgesDlg::ClickOnOk()
114 if ( ClickOnApply() )
118 //=================================================================================
119 // function : ClickOnApply()
121 //=================================================================================
122 bool RepairGUI_RemoveExtraEdgesDlg::ClickOnApply()
129 myEditCurrentArgument->setText("");
130 myObject = GEOM::GEOM_Object::_nil();
138 //=================================================================================
139 // function : SelectionIntoArgument()
140 // purpose : Called when selection as changed or other case
141 // : used only by SelectButtonC1A1 (LineEditC1A1)
142 //=================================================================================
143 void RepairGUI_RemoveExtraEdgesDlg::SelectionIntoArgument()
145 myEditCurrentArgument->setText("");
148 if(myEditCurrentArgument == GroupPoints->LineEdit1) {
149 if (IObjectCount() != 1) {
150 if (myEditCurrentArgument == GroupPoints->LineEdit1)
157 Standard_Boolean testResult = Standard_False;
158 GEOM::GEOM_Object_ptr aSelectedObject =
159 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
164 if (myEditCurrentArgument == GroupPoints->LineEdit1) {
165 myObject = aSelectedObject;
169 myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
172 //=================================================================================
173 // function : SetEditCurrentArgument()
175 //=================================================================================
176 void RepairGUI_RemoveExtraEdgesDlg::SetEditCurrentArgument()
178 if( sender() == GroupPoints->PushButton1 )
180 GroupPoints->LineEdit1->setFocus();
181 myEditCurrentArgument = GroupPoints->LineEdit1;
183 SelectionIntoArgument();
187 //=================================================================================
188 // function : LineEditReturnPressed()
190 //=================================================================================
191 void RepairGUI_RemoveExtraEdgesDlg::LineEditReturnPressed()
193 if( sender() == GroupPoints->LineEdit1 )
195 myEditCurrentArgument = GroupPoints->LineEdit1;
196 GEOMBase_Skeleton::LineEditReturnPressed();
201 //=================================================================================
202 // function : ActivateThisDialog()
204 //=================================================================================
205 void RepairGUI_RemoveExtraEdgesDlg::ActivateThisDialog()
207 GEOMBase_Skeleton::ActivateThisDialog();
208 connect(((SalomeApp_Application*)(SUIT_Session::session()->activeApplication()))->selectionMgr(),
209 SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument()));
215 //=================================================================================
216 // function : enterEvent()
217 // purpose : Mouse enter onto the dialog to activate it
218 //=================================================================================
219 void RepairGUI_RemoveExtraEdgesDlg::enterEvent(QEvent* e)
221 if ( !GroupConstructors->isEnabled() )
222 ActivateThisDialog();
226 //=================================================================================
227 // function : closeEvent()
229 //=================================================================================
230 void RepairGUI_RemoveExtraEdgesDlg::closeEvent(QCloseEvent* e)
232 GEOMBase_Skeleton::closeEvent( e );
235 //=================================================================================
236 // function : activateSelection
237 // purpose : activate selection of solids and compounds
238 //=================================================================================
239 void RepairGUI_RemoveExtraEdgesDlg::activateSelection()
241 TColStd_MapOfInteger aTypes;
242 aTypes.Add( GEOM_SOLID );
243 aTypes.Add( GEOM_COMPOUND );
244 globalSelection( aTypes );
247 //=================================================================================
248 // function : createOperation
250 //=================================================================================
251 GEOM::GEOM_IOperations_ptr RepairGUI_RemoveExtraEdgesDlg::createOperation()
253 return getGeomEngine()->GetIBlocksOperations( getStudyId() );
256 //=================================================================================
257 // function : isValid
259 //=================================================================================
260 bool RepairGUI_RemoveExtraEdgesDlg::isValid( QString& msg )
265 //=================================================================================
266 // function : execute
268 //=================================================================================
269 bool RepairGUI_RemoveExtraEdgesDlg::execute( ObjectList& objects )
271 GEOM::GEOM_Object_var anObj;
273 anObj = GEOM::GEOM_IBlocksOperations::_narrow(getOperation())->RemoveExtraEdges(myObject);
275 if ( !anObj->_is_nil() )
276 objects.push_back( anObj._retn() );