1 // Copyright (C) 2007-2015 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 GEOMGUI : GUI for Geometry component
21 // File : EntityGUI_SurfFromFaceDlg.cxx
23 #include "EntityGUI_SurfFromFaceDlg.h"
24 #include <GeometryGUI.h>
28 #include <SUIT_Session.h>
29 #include <SUIT_ResourceMgr.h>
30 #include <SalomeApp_Application.h>
31 #include <LightApp_SelectionMgr.h>
34 //=================================================================================
35 // class : EntityGUI_SurfFromFaceDlg
37 //=================================================================================
38 EntityGUI_SurfFromFaceDlg::EntityGUI_SurfFromFaceDlg
39 (GeometryGUI *theGeometryGUI,
43 : GEOMBase_Skeleton (theGeometryGUI, parent, modal, fl),
46 QPixmap image0(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SURFACE_FROM_FACE")));
47 QPixmap image1(SUIT_Session::session()->resourceMgr()->loadPixmap("GEOM", tr("ICON_SELECT")));
49 setWindowTitle(tr("GEOM_SURF_FROM_FACE_TITLE"));
51 /***************************************************************/
53 mainFrame()->GroupConstructors->setTitle(tr("GEOM_SURF_FROM_FACE"));
54 mainFrame()->RadioButton1->setIcon(image0);
55 mainFrame()->RadioButton2->close();
56 mainFrame()->RadioButton3->close();
59 myGroup = new DlgRef_1Sel(centralWidget());
60 myGroup->GroupBox1->setTitle(tr("GEOM_ARGUMENTS"));
61 myGroup->TextLabel1->setText(tr("GEOM_FACE"));
62 myGroup->PushButton1->setIcon(image1);
63 myGroup->LineEdit1->setReadOnly(true);
65 QVBoxLayout* layout = new QVBoxLayout(centralWidget());
66 layout->setMargin(0); layout->setSpacing(6);
67 layout->addWidget(myGroup);
69 setHelpFileName("create_surface_from_face_page.html");
74 //=================================================================================
75 // function : ~EntityGUI_SurfFromFaceDlg()
77 //=================================================================================
78 EntityGUI_SurfFromFaceDlg::~EntityGUI_SurfFromFaceDlg()
82 //=================================================================================
85 //=================================================================================
86 void EntityGUI_SurfFromFaceDlg::Init()
88 initName(tr("GEOM_SURF_FROM_FACE_NAME"));
89 showOnlyPreviewControl();
91 /* signals and slots connections */
92 connect(myGroup->PushButton1, SIGNAL(clicked()),
93 this, SLOT(SetEditCurrentArgument()));
94 connect(myGeomGUI->getApp()->selectionMgr(),
95 SIGNAL(currentSelectionChanged()),
96 this, SLOT(SelectionIntoArgument()));
97 connect(myGeomGUI, SIGNAL(SignalDeactivateActiveDialog()),
98 this, SLOT(DeactivateActiveDialog()));
99 connect(myGeomGUI, SIGNAL(SignalCloseAllDialogs()),
100 this, SLOT(ClickOnCancel()));
101 connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk()));
102 connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply()));
104 myEditCurrentArgument = myGroup->LineEdit1;
105 myGroup->LineEdit1->setReadOnly(true);
106 SelectionIntoArgument();
109 //=================================================================================
110 // function : SelectionIntoArgument
111 // purpose : Called when selection is changed
112 //=================================================================================
113 void EntityGUI_SurfFromFaceDlg::SelectionIntoArgument()
116 myEditCurrentArgument->setText("");
119 GEOM::GeomObjPtr aSelectedObject = getSelected(TopAbs_FACE);
121 if (aSelectedObject) {
122 myEditCurrentArgument->setText(GEOMBase::GetName(aSelectedObject.get()));
123 myFace = aSelectedObject;
129 //=================================================================================
130 // function : SetEditCurrentArgument()
132 //=================================================================================
133 void EntityGUI_SurfFromFaceDlg::SetEditCurrentArgument()
135 QPushButton* send = (QPushButton*)sender();
137 if (send == myGroup->PushButton1) {
138 myEditCurrentArgument->setFocus();
139 SelectionIntoArgument();
143 //=================================================================================
144 // function : ActivateThisDialog
146 //=================================================================================
147 void EntityGUI_SurfFromFaceDlg::ActivateThisDialog()
149 GEOMBase_Skeleton::ActivateThisDialog();
150 connect(myGeomGUI->getApp()->selectionMgr(),
151 SIGNAL(currentSelectionChanged()),
152 this, SLOT(SelectionIntoArgument()));
153 SelectionIntoArgument();
156 //=================================================================================
157 // function : enterEvent()
159 //=================================================================================
160 void EntityGUI_SurfFromFaceDlg::enterEvent (QEvent*)
162 if (!mainFrame()->GroupConstructors->isEnabled())
163 ActivateThisDialog();
166 //=================================================================================
167 // function : createOperation
169 //=================================================================================
170 GEOM::GEOM_IOperations_ptr EntityGUI_SurfFromFaceDlg::createOperation()
172 return myGeomGUI->GetGeomGen()->GetIShapesOperations(getStudyId());
175 //=================================================================================
176 // function : isValid
178 //=================================================================================
179 bool EntityGUI_SurfFromFaceDlg::isValid (QString& msg)
184 //=================================================================================
185 // function : execute
187 //=================================================================================
188 bool EntityGUI_SurfFromFaceDlg::execute (ObjectList& objects)
190 GEOM::GEOM_IShapesOperations_var anOper =
191 GEOM::GEOM_IShapesOperations::_narrow(getOperation());
192 GEOM::GEOM_Object_var anObj = anOper->MakeSurfaceFromFace(myFace.get());
194 if (!anObj->_is_nil()) {
195 objects.push_back(anObj._retn());
201 //=================================================================================
202 // function : ClickOnOk()
204 //=================================================================================
205 void EntityGUI_SurfFromFaceDlg::ClickOnOk()
207 setIsApplyAndClose(true);
213 //=================================================================================
214 // function : ClickOnApply()
216 //=================================================================================
217 bool EntityGUI_SurfFromFaceDlg::ClickOnApply()
227 //=================================================================================
228 // function : getSourceObjects
229 // purpose : virtual method to get source objects
230 //=================================================================================
231 QList<GEOM::GeomObjPtr> EntityGUI_SurfFromFaceDlg::getSourceObjects()
233 QList<GEOM::GeomObjPtr> res;