1 // GEOM GEOMGUI : GUI for Geometry component
3 // This library is distributed in the hope that it will be useful,
4 // but WITHOUT ANY WARRANTY; without even the implied warranty of
5 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6 // Lesser General Public License for more details.
8 // You should have received a copy of the GNU Lesser General Public
9 // License along with this library; if not, write to the Free Software
10 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
12 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
14 // File : RepairGUI_RemoveExtraEdgesDlg.cxx
15 // Author : Michael Zorin, Open CASCADE S.A.S.
18 #include "RepairGUI_RemoveExtraEdgesDlg.h"
21 #include <GeometryGUI.h>
24 #include <SalomeApp_Application.h>
25 #include <LightApp_SelectionMgr.h>
26 #include <SUIT_Session.h>
27 #include <SUIT_ResourceMgr.h>
29 #include <GEOMImpl_Types.hxx>
31 #include <TColStd_MapOfInteger.hxx>
33 //=================================================================================
34 // class : RepairGUI_RemoveExtraEdgesDlg()
35 // purpose : Constructs a RepairGUI_RemoveExtraEdgesDlg which is a child of 'parent', with the
36 // name 'name' and widget flags set to 'f'.
37 // The dialog will by default be modeless, unless you set 'modal' to
38 // TRUE to construct a modal dialog.
39 //=================================================================================
40 RepairGUI_RemoveExtraEdgesDlg::RepairGUI_RemoveExtraEdgesDlg( GeometryGUI* theGeometryGUI, QWidget* parent,
42 : GEOMBase_Skeleton( theGeometryGUI, parent, modal )
44 QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_REMOVE_EXTRA_EDGES" ) ) );
45 QPixmap image1( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_SELECT" ) ) );
47 setWindowTitle( tr( "GEOM_REMOVE_EXTRA_EDGES_TITLE" ) );
49 /***************************************************************/
50 mainFrame()->GroupConstructors->setTitle(tr("GEOM_REMOVE_EXTRA_EDGES_TITLE"));
51 mainFrame()->RadioButton1->setIcon( image0 );
52 mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
53 mainFrame()->RadioButton2->close();
54 mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
55 mainFrame()->RadioButton3->close();
57 GroupPoints = new DlgRef_1Sel( centralWidget() );
58 GroupPoints->GroupBox1->setTitle( tr( "GEOM_REMOVE_EXTRA_EDGES" ) );
59 GroupPoints->TextLabel1->setText( tr( "GEOM_SELECTED_SHAPE" ) );
60 GroupPoints->PushButton1->setIcon( image1 );
61 GroupPoints->LineEdit1->setReadOnly( true );
63 QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
64 layout->setMargin( 0 ); layout->setSpacing( 6 );
65 layout->addWidget( GroupPoints );
67 /***************************************************************/
69 setHelpFileName( "remove_extra_edges_operation_page.html" );
75 //=================================================================================
76 // function : ~RepairGUI_RemoveExtraEdgesDlg()
77 // purpose : Destroys the object and frees any allocated resources
78 //=================================================================================
79 RepairGUI_RemoveExtraEdgesDlg::~RepairGUI_RemoveExtraEdgesDlg()
84 //=================================================================================
87 //=================================================================================
88 void RepairGUI_RemoveExtraEdgesDlg::Init()
91 myEditCurrentArgument = GroupPoints->LineEdit1;
97 /* signals and slots connections */
98 connect( buttonOk(), SIGNAL( clicked() ), this, SLOT( ClickOnOk() ) );
99 connect( buttonApply(), SIGNAL( clicked() ), this, SLOT( ClickOnApply() ) );
101 connect( GroupPoints->PushButton1, SIGNAL( clicked() ), this, SLOT( SetEditCurrentArgument() ) );
102 connect( GroupPoints->LineEdit1, SIGNAL( returnPressed() ), this, SLOT( LineEditReturnPressed() ) );
104 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
105 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
107 initName( tr( "REMOVE_EXTRA_EDGES_NEW_OBJ_NAME" ) );
111 //=================================================================================
112 // function : ClickOnOk()
113 // purpose : Same than click on apply but close this dialog.
114 //=================================================================================
115 void RepairGUI_RemoveExtraEdgesDlg::ClickOnOk()
117 if ( ClickOnApply() )
121 //=================================================================================
122 // function : ClickOnApply()
124 //=================================================================================
125 bool RepairGUI_RemoveExtraEdgesDlg::ClickOnApply()
132 myEditCurrentArgument->setText( "" );
133 myObject = GEOM::GEOM_Object::_nil();
141 //=================================================================================
142 // function : SelectionIntoArgument()
143 // purpose : Called when selection as changed or other case
144 // : used only by SelectButtonC1A1 (LineEditC1A1)
145 //=================================================================================
146 void RepairGUI_RemoveExtraEdgesDlg::SelectionIntoArgument()
148 myEditCurrentArgument->setText( "" );
151 if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
152 if ( IObjectCount() != 1 ) {
153 if ( myEditCurrentArgument == GroupPoints->LineEdit1 )
160 Standard_Boolean testResult = Standard_False;
161 GEOM::GEOM_Object_ptr aSelectedObject =
162 GEOMBase::ConvertIOinGEOMObject( firstIObject(), testResult );
167 if ( myEditCurrentArgument == GroupPoints->LineEdit1 ) {
168 myObject = aSelectedObject;
172 myEditCurrentArgument->setText( GEOMBase::GetName( aSelectedObject ) );
175 //=================================================================================
176 // function : SetEditCurrentArgument()
178 //=================================================================================
179 void RepairGUI_RemoveExtraEdgesDlg::SetEditCurrentArgument()
181 if( sender() == GroupPoints->PushButton1 ) {
182 GroupPoints->LineEdit1->setFocus();
183 myEditCurrentArgument = GroupPoints->LineEdit1;
185 SelectionIntoArgument();
189 //=================================================================================
190 // function : LineEditReturnPressed()
192 //=================================================================================
193 void RepairGUI_RemoveExtraEdgesDlg::LineEditReturnPressed()
195 if ( sender() == GroupPoints->LineEdit1 ) {
196 myEditCurrentArgument = GroupPoints->LineEdit1;
197 GEOMBase_Skeleton::LineEditReturnPressed();
202 //=================================================================================
203 // function : ActivateThisDialog()
205 //=================================================================================
206 void RepairGUI_RemoveExtraEdgesDlg::ActivateThisDialog()
208 GEOMBase_Skeleton::ActivateThisDialog();
209 connect( ( (SalomeApp_Application*)( SUIT_Session::session()->activeApplication() ) )->selectionMgr(),
210 SIGNAL( currentSelectionChanged() ), this, SLOT( SelectionIntoArgument() ) );
216 //=================================================================================
217 // function : enterEvent()
218 // purpose : Mouse enter onto the dialog to activate it
219 //=================================================================================
220 void RepairGUI_RemoveExtraEdgesDlg::enterEvent(QEvent* e)
222 if ( !mainFrame()->GroupConstructors->isEnabled() )
223 ActivateThisDialog();
227 //=================================================================================
228 // function : activateSelection
229 // purpose : activate selection of solids and compounds
230 //=================================================================================
231 void RepairGUI_RemoveExtraEdgesDlg::activateSelection()
233 TColStd_MapOfInteger aTypes;
234 aTypes.Add( GEOM_SOLID );
235 aTypes.Add( GEOM_COMPOUND );
236 globalSelection( aTypes );
239 //=================================================================================
240 // function : createOperation
242 //=================================================================================
243 GEOM::GEOM_IOperations_ptr RepairGUI_RemoveExtraEdgesDlg::createOperation()
245 return getGeomEngine()->GetIBlocksOperations( getStudyId() );
248 //=================================================================================
249 // function : isValid
251 //=================================================================================
252 bool RepairGUI_RemoveExtraEdgesDlg::isValid( QString& msg )
257 //=================================================================================
258 // function : execute
260 //=================================================================================
261 bool RepairGUI_RemoveExtraEdgesDlg::execute( ObjectList& objects )
263 GEOM::GEOM_Object_var anObj;
265 anObj = GEOM::GEOM_IBlocksOperations::_narrow( getOperation() )->RemoveExtraEdges( myObject );
267 if ( !anObj->_is_nil() )
268 objects.push_back( anObj._retn() );